<<< Date Index >>>     <<< Thread Index >>>

Re: [PATCH] fix dereferencing of type-punned pointer



* Thomas Roessler <roessler@xxxxxxxxxxxxxxxxxx> [Sep 03. 2003 19:38]:
> The following change don't seem to make sense to me.  Is there any
> reason why an argument to FREE would be cast to (void **)?

It shouldn't, it's a typo. It should be (void *) to be like before,
since safe_free now takes (void *).

> > -     FREE (MuttVars[idx].data);
> > +     FREE ((void **)MuttVars[idx].data);
> >        }
> >        else if (query || *s->dptr != '=')
> >        {
> > @@ -930,7 +930,7 @@
> >          if (DTYPE (MuttVars[idx].type) == DT_ADDR)
> >       rfc822_free_address ((ADDRESS **) MuttVars[idx].data);
> >          else
> > -     FREE (MuttVars[idx].data);
> > +     FREE ((void **)MuttVars[idx].data);
> >  
> >          mutt_extract_token (tmp, s, 0);
> >          if (DTYPE (MuttVars[idx].type) == DT_PATH)
> > Index: lib.c
> > ===================================================================
> 
> ... 
> 
> > -void safe_free (void **p)
> > +void safe_free (void *ptr)
> >  {
> > +  void **p = (void **)ptr;
> >    if (*p)
> 
> ... 
> 
> > Index: lib.h
> > ===================================================================
> > RCS file: /home/roessler/cvs/mutt/lib.h,v
> > retrieving revision 3.6
> > diff -u -r3.6 lib.h
> > --- lib.h   11 Dec 2002 15:20:21 -0000      3.6
> > +++ lib.h   13 Aug 2003 19:28:36 -0000
> > @@ -76,7 +76,7 @@
> >  # define MUTT_FORMAT2(a,b) _MUTT_FORMAT_1(a, b)
> >  
> >  
> > -# define FREE(x) safe_free((void **)x)
> > +# define FREE(x) safe_free(x)



-- 
Mads Martin Joergensen, http://mmj.dk
"Why make things difficult, when it is possible to make them cryptic
 and totally illogical, with just a little bit more effort?"
                                -- A. P. J.