[flac-dev] about libFLAC/metadata_object.c

Erik de Castro Lopo mle+la at mega-nerd.com
Fri Jul 3 19:26:50 PDT 2015


lvqcl wrote:

> 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.

Its actually deeper than that. Passing a NULL pointer to the free() function
is perfectly safe as that is specified (by the C standard) to be a NO-OP.

Currently working on a patch to remove all these from metadata_object.c.

Erik
-- 
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/


More information about the flac-dev mailing list