Fixed segmentation fault in Qt trace logger when changing from a large buffer size to a smaller buffer size. Ensure that buffer head and tail pointers are reset as well. Fixed memory leak with old trace log buffer not being freed when allocating the new buffer size.
This commit is contained in:
parent
2169dd07fb
commit
e2716ae2c5
|
@ -967,6 +967,11 @@ int initTraceLogBuffer(int maxRecs)
|
|||
|
||||
size = maxRecs * sizeof(traceRecord_t);
|
||||
|
||||
if ( recBuf != NULL )
|
||||
{
|
||||
free(recBuf); recBuf = NULL;
|
||||
}
|
||||
|
||||
recBuf = (traceRecord_t *)malloc(size);
|
||||
|
||||
if (recBuf)
|
||||
|
@ -978,6 +983,7 @@ int initTraceLogBuffer(int maxRecs)
|
|||
{
|
||||
recBufMax = 0;
|
||||
}
|
||||
recBufHead = recBufTail = 0;
|
||||
}
|
||||
return recBuf == NULL;
|
||||
}
|
||||
|
@ -1001,10 +1007,14 @@ static void pushToLogBuffer(traceRecord_t &rec)
|
|||
recBuf[recBufHead] = rec;
|
||||
recBufHead = (recBufHead + 1) % recBufMax;
|
||||
|
||||
if ( logging )
|
||||
{ // Warning that an buffer overrun has occurred,
|
||||
// This means that some instructions have not been written to the log.
|
||||
if (recBufHead == recBufTail)
|
||||
{
|
||||
printf("Trace Log Overrun!!!\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------
|
||||
static void pushMsgToLogBuffer(const char *msg)
|
||||
|
|
Loading…
Reference in New Issue