Closed zvezdochiot closed 5 years ago
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: https://github.com/knik0/faac/blob/40fffb1f696ef1abaf7a0a0ec4c4c3d0cde790b1/common/Cfaac/CRegistry.cpp#L317-L320 https://github.com/knik0/faac/blob/40fffb1f696ef1abaf7a0a0ec4c4c3d0cde790b1/common/Cfaac/CRegistry.cpp#L343-L345
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.
https://github.com/knik0/faac/blob/40fffb1f696ef1abaf7a0a0ec4c4c3d0cde790b1/common/Cfaac/CRegistry.cpp#L205-L209
Maybe:
?
https://github.com/knik0/faac/blob/40fffb1f696ef1abaf7a0a0ec4c4c3d0cde790b1/common/Cfaac/CRegistry.cpp#L225-L229
Maybe:
?
https://github.com/knik0/faac/blob/40fffb1f696ef1abaf7a0a0ec4c4c3d0cde790b1/common/Cfaac/CRegistry.cpp#L343-L345
Maybe:
?