I delete arrays always with delete[]
. But HP Fortify shows a Memory Leak for that. What is wrong with my code?
unsigned buflen = SapUcConverter::getFormatBufferLength(len);
char* buffer = new char[buflen]; // Here is the memory leak marked by Fortify
if(valueCanBeLogged) {
LOGMSG(_DBUG, "nameForLog=%s, len=%d, sapuc='%.*s'",
nameForLog, len, buflen,
SapUcConverter::format(buffer, sapuc, len));
} else {
LOGMSG(_DBUG, "nameForLog=%s, len=#####, sapuc=#####");
}
delete[] buffer;