[flac-dev] about libFLAC/metadata_object.c
lvqcl
lvqcl.mail at gmail.com
Fri Jul 3 17:56:30 PDT 2015
lvqcl <lvqcl.mail at gmail.com> wrote:
> 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.
Another example is in static_metadata_clear() in src\flac\encode.c:
for(i = 0; i < m->num_metadata; i++)
if(m->needs_delete[i])
FLAC__metadata_object_delete(m->metadata[i]);
if(m->metadata)
free(m->metadata);
if(m->needs_delete)
free(m->needs_delete);
Here m->metadata and m->needs_delete were first dereferenced
and then (unnecessarily) checked against NULL.
More information about the flac-dev
mailing list