8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 20:03:02 +01:00

Fixe bug #8083 : AV when writting into internal trace log

This commit is contained in:
Vlad Khorsun 2024-04-16 11:40:51 +03:00
parent 003b2e0a77
commit 4cc3ebe37d

View File

@ -238,10 +238,24 @@ void TraceLog::extend(FB_SIZE_T size)
const FB_SIZE_T toMoveR = oldSize - header->readPos; const FB_SIZE_T toMoveR = oldSize - header->readPos;
char* data = reinterpret_cast<char*> (header); char* data = reinterpret_cast<char*> (header);
const FB_SIZE_T deltaSize = newSize - oldSize;
if (toMoveW < toMoveR) if (toMoveW < toMoveR)
{ {
memcpy(data + oldSize, data + sizeof(TraceLogHeader), toMoveW); if (toMoveW <= deltaSize)
header->writePos = oldSize + toMoveW; {
memcpy(data + oldSize, data + sizeof(TraceLogHeader), toMoveW);
header->writePos = oldSize + toMoveW;
if (header->writePos == header->allocated)
header->writePos = sizeof(TraceLogHeader);
}
else
{
memcpy(data + oldSize, data + sizeof(TraceLogHeader), deltaSize);
memcpy(data + sizeof(TraceLogHeader), data + sizeof(TraceLogHeader) + deltaSize, toMoveW - deltaSize);
header->writePos -= deltaSize;
}
} }
else else
{ {