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

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



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 **)?

On 2003-08-13 21:47:10 +0200, Mads Martin Joergensen wrote:

> ===================================================================
> RCS file: /home/roessler/cvs/mutt/init.c,v
> retrieving revision 3.15
> diff -u -r3.15 init.c
> --- init.c    5 Aug 2003 13:55:47 -0000       3.15
> +++ init.c    13 Aug 2003 19:28:36 -0000
> @@ -901,7 +901,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);
>        }
>        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)


-- 
Thomas Roessler · Personal soap box at <http://log.does-not-exist.org/>.