Closed elfring closed 6 years ago
Removing NULL pointer check there creates a potential NULL-pointer dereference bug. I strongly advise against removing there kinds of checks.
Moreover, those functions are not used by INAV and are optimized out by GCC
A POSIX compliant free() function will return immediately if a null pointer was passed. Thus I do not see a need to repeat such a sanity check.
If you would read the code you'll notice that a point is dereferenced first and then freed:
/* DeInit physical Interface components */
if(pdev->pClassData != NULL)
{
((USBD_AUDIO_ItfTypeDef *)pdev->pUserData)->DeInit(0);
USBD_free(pdev->pClassData);
pdev->pClassData = NULL;
}
Regardless, we don't have dynamic memory allocation in INAV, these functions are not used and they are in a 3rd party library which may (and will) be updated eventually (discarding the fixes).
An extra null pointer check is not needed in functions like the following.