[PATCH] Remove more superfluous if(p) checks around free(p)

Matt Turner mattst88 at gmail.com
Sun Jun 6 06:16:20 PDT 2010


On Sun, Jun 6, 2010 at 9:14 AM, Mikhail Gusarov <dottedmag at dottedmag.net> wrote:
>
> Twas brillig at 10:03:16 06.06.2010 UTC-03 when fcarrijo at yahoo.com.br
> did gyre and gimble:
>
>  FC> By the way, the hunk below sounds rather fishy, right?
>
>  >> @@ -109,14 +107,10 @@ RRCreateOutputProperty (Atom property)
>  >>  static void
>  >>  RRDestroyOutputProperty (RRPropertyPtr prop)
>  >>  {
>  >> -    if (prop->valid_values)
>  >> -        free(prop->valid_values);
>  >> -    if (prop->current.data)
>  >> -        free(prop->current.data);
>  >> -    if (prop->pending.data)
>  >> -        free(prop->pending.data);
>  >> -    if (prop->valid_values)
>  >> -        free(prop->valid_values);
>  >> +    free(prop->valid_values);
>  >> +    free(prop->current.data);
>  >> +    free(prop->pending.data);
>  >> +    free(prop->valid_values);
>  >>      free(prop);
>  >>  }
>
> Hmm, why? Prop is zero-initialized on allocation, so it's okay.
>
> --
>  http://fossarchy.blogspot.com/
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
>

I didn't see it at first, but prop->valid_values is in there twice
(first call to free and second-to-last). Nothing your patch did, it
was like that already.

Matt


More information about the xorg-devel mailing list