This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Replace potentially unsafe alloca with xmalloc/xfree in value_concat
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: Siddhesh Poyarekar <siddhesh at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Fri, 14 Sep 2012 13:37:05 +0200
- Subject: Re: [PATCH] Replace potentially unsafe alloca with xmalloc/xfree in value_concat
- References: <20120914144629.67e493d0@spoyarek>
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