I'm not familiar with C as much as with C++ but I found my self in need to debug C application and after even succeeded to do so, but I'm not sure if my fix indeed is correct.
Here is a code:
FcValueList **value = NULL;
value = (FcValueList **) malloc (SIZEOF_VOID_P * nobjs);
// other code...
if (value)
free (value);
The FcValueList is a structure and SIZEOF_VOID_P is a size of void pointer. The above code does not work because the value is "unable to read memory"
So I applied following fix and the code worked with app exiting with 0:
value = (FcValueList **) malloc (SIZEOF_VOID_P * nobjs);
// other code...
if (*value)
free (value);
Is my fix correct? and if not what would be correct then?