This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Replace potentially unsafe alloca with xmalloc/xfree in value_concat


Hi Siddhesh,

On Fri, 14 Sep 2012 11:16:29 +0200, Siddhesh Poyarekar wrote:
> --- gdb/valarith.c	16 Aug 2012 07:36:20 -0000	1.105
> +++ gdb/valarith.c	14 Sep 2012 08:31:38 -0000
> @@ -668,9 +668,11 @@
>        if (TYPE_CODE (type2) == TYPE_CODE_STRING
>  	  || TYPE_CODE (type2) == TYPE_CODE_CHAR)
>  	{
> +	  struct cleanup *back_to;

Empty line after declarations.


>  	  count = longest_to_int (value_as_long (inval1));
>  	  inval2len = TYPE_LENGTH (type2);
> -	  ptr = (char *) alloca (count * inval2len);
> +	  ptr = (char *) xmalloc (count * inval2len);
> +	  back_to = make_cleanup (xfree, ptr);


OK with that change.


Thanks,
Jan


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]