[flac-dev] about libFLAC/metadata_object.c

lvqcl lvqcl.mail at gmail.com
Sun Jun 28 08:01:04 PDT 2015


There are two functions:

     static void vorbiscomment_entry_array_delete_(FLAC__StreamMetadata_VorbisComment_Entry *object_array, unsigned num_comments);

and

     static void cuesheet_track_array_delete_(FLAC__StreamMetadata_CueSheet_Track *object_array, unsigned num_tracks);


which first dereference object_array and only then check it for NULL:

             free(object_array[i].indices);
         ...
         ...
         if(0 != object_array)
             free(object_array);

Currently the condition "if(0 != object_array)" is not necessary because libFLAC
always checks the first argument of these static functions before calling them.

Also the check was added in the commit "fix null pointer handling in metadata object routines":
http://git.xiph.org/?p=flac.git;a=commitdiff;h=7294309ba6bc642a5907f4246b7e085c93f23144
The function wasn't static back then.

So it make sense either to remove this unnecessary check or to make it much earlier,
before dereferencing.


More information about the flac-dev mailing list