cppcheck -f -v . 2>cppcheck.log >/dev/null
Closed this issue · 6 comments
faac/common/Cfaac/CRegistry.cpp
Lines 205 to 209 in 40fffb1
Maybe:
BYTE *tempVal=new BYTE[slen];
...
delete *tempVal;
?
faac/common/Cfaac/CRegistry.cpp
Lines 225 to 229 in 40fffb1
Maybe:
...
delete *tempVal;
?
faac/common/Cfaac/CRegistry.cpp
Lines 343 to 345 in 40fffb1
Maybe:
*dest=NULL;
...
?
What exactly does cppcheck print? It doesn't help if you just post the code lines.
@fabiangreffrath say> What exactly does cppcheck print?
git/knik0/faac/common/Cfaac$ cat cppcheck.log
[CRegistry.cpp:209]: (error) Mismatching allocation and deallocation: tempVal
[CRegistry.cpp:229]: (error) Mismatching allocation and deallocation: tempVal
[CRegistry.cpp:345]: (error) Null pointer dereference
In the first two cases, replace delete tempVal
with delete[] tempVal
. You are pretty sure right with your fix to the third error.
@fabiangreffrath say> You are pretty sure right with your fix to the third error.
See:
faac/common/Cfaac/CRegistry.cpp
Lines 317 to 320 in 40fffb1
faac/common/Cfaac/CRegistry.cpp
Lines 343 to 345 in 40fffb1
Maybe:
int CRegistry::GetSetValN(char *keyStr, BYTE *defData, DWORD defSize, BYTE **dest)
{
long retVal;
DWORD size;
*dest=NULL;
if((retVal=RegQueryValueEx(regKey , keyStr , NULL , NULL, NULL, &size))==ERROR_SUCCESS)
if(*dest=(BYTE *)malloc(size+1))
retVal=RegQueryValueEx(regKey , keyStr , NULL , NULL, (BYTE *)*dest , &size);
if(retVal!=ERROR_SUCCESS)
{
if(*dest)
free(*dest);
if(!defData)
return 0;
size=defSize;
if(!(*dest=(BYTE *)malloc(size)))
return 0;
memcpy(*dest,defData,size);
RegSetValueEx(regKey , keyStr , NULL , REG_BINARY , (BYTE *)*dest , size);
}
return size;
}
?
Would you create a PR for this?
@fabiangreffrath say> Would you create a PR for this?
No time.