The codebase I am working has a vast amount of legacy code writting in a mizture of 'C' and 'C++' and includes its own memory allocation functions which hasve the following signature:
STATUS osMemAlloc(void** ptr, size_t sz);
This fuction is generally used throught the codebase as:
DeviceInfo *device = NULL; if (osMemAlloc((void**)&device, sizeof(DeviceInfo)) == OS_OK)
{
// code that de-references device goes here
}
With an older vesion of CppCheck (Version 1.84) this function was defined as a macro in a cppcheck.cfg file as:
This now causes nullPointer derference errors in the code that uses a pointer allocated by osMemAlloc. I belieev this is because the cast to (void**) is causing CppCheck to miss the assignement of a value to teh pointer.
The codebase I am working has a vast amount of legacy code writting in a mizture of 'C' and 'C++' and includes its own memory allocation functions which hasve the following signature:
This fuction is generally used throught the codebase as:
With an older vesion of CppCheck (Version 1.84) this function was defined as a macro in a cppcheck.cfg file as:
This now causes nullPointer derference errors in the code that uses a pointer allocated by osMemAlloc. I belieev this is because the cast to (void**) is causing CppCheck to miss the assignement of a value to teh pointer.
Here is a full example
The ouput from CppCheck (version 2.3) is as follows:
When the same code is passed to the Older version of CppCheck (1.84) no errors are reported.
Thanks! I created https://trac.cppcheck.net/ticket/10047
Thank Daniel when its fixed I can verify it on a very large legacy codebase.