The cpp-check error is: error mismatchAllocDealloc false Mismatching allocation and deallocation: val2
What should I do to fix this error?
void MainWindow::ParseDemo(char *pBuf)
{
char* val2 = new char[256];
for (int i = 0; i < 254; i++)
{
val2[i] = pBuf[i+305];
}
val2[254] = 0; // 0-Termination
QString sunit(val2);
DoStuff(sunit);
delete val2;
// ...
}
free(val2);
. – Illyrian