[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gdb-patches
Subject:    [RFA] Typedef'd method parameters [1/4]
From:       jan.kratochvil () redhat ! com (Jan Kratochvil)
Date:       2011-04-27 18:46:00
Message-ID: 20110427184622.GA9667 () host1 ! jankratochvil ! net
[Download RAW message or body]

On Thu, 21 Apr 2011 23:15:29 +0200, Keith Seitz wrote:
> --- cp-name-parser.y	18 Mar 2011 13:51:41 -0000	1.20
> +++ cp-name-parser.y	20 Apr 2011 23:04:46 -0000
[...]
> @@ -1966,23 +1961,46 @@ cp_comp_to_string (struct demangle_compo
>  			       &err);
>  }
>  
> +/* Free any memory associated with the given PARSE_INFO.  */
> +
> +void
> +cp_demangled_name_parse_free (struct demangle_parse_info *parse_info)
> +{
> +  struct demangle_info *info = parse_info->info;
> +
> +  /* Free any allocated chunks of memory for the parse.  */
> +  while (info != NULL)
> +    {
> +      struct demangle_info *next = info->next;

Missing empty line.

> +      free (info);
> +      info = next;
> +    }
> +
> +  /* Free the parser info.  */
> +  free (parse_info);
> +}
> +
[...]
> --- python/py-type.c	26 Jan 2011 20:53:45 -0000	1.18
> +++ python/py-type.c	20 Apr 2011 23:04:47 -0000
[...]
> @@ -613,12 +616,14 @@ typy_legacy_template_argument (struct ty
>  
>    if (! demangled)
>      {
> +      cp_demangled_name_parse_free (info);
>        PyErr_Format (PyExc_RuntimeError, _("No argument %d in template."),
>  		    argno);
>        return NULL;
>      }
>  
>    argtype = typy_lookup_type (demangled->u.s_binary.left, block);
> +  cp_demangled_name_parse_free (info);

typy_lookup_type is a normal GDB code which could throw an exception leaking
INFO.  (I understand it is a pity without C++.)


>    if (! argtype)
>      return NULL;
>  


Thanks,
Jan


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic