Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* [patch]: Fix memory leak of target-descriptions.c
@ 2008-06-30  8:58 teawater
  2008-07-03 23:15 ` Michael Snyder
  0 siblings, 1 reply; 3+ messages in thread
From: teawater @ 2008-06-30  8:58 UTC (permalink / raw)
  To: gdb

target-descriptions.c has a memory leek in function
maint_print_c_tdesc_cmd. char *function is xmalloc at line 1016.
There are returns at the end of this function without calling free.
And this variable is just used in this function. So I change it to
"alloca".
This patch is for the GDB cvs version.

2008-06-21  Hui Zhu  <teawater@gmail.com>
       * target-descriptions.c (maint_print_c_tdesc_cmd): Fix a memory leak.

--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -1013,7 +1013,7 @@ maint_print_c_tdesc_cmd (char *args, int
     error (_("The current target description did not come from an XML file."));

   filename = lbasename (target_description_filename);
-  function = xmalloc (strlen (filename) + 1);
+  function = alloca (strlen (filename) + 1);
   for (inp = filename, outp = function; *inp != '\0'; inp++)
     if (*inp == '.')
       break;


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch]: Fix memory leak of target-descriptions.c
  2008-06-30  8:58 [patch]: Fix memory leak of target-descriptions.c teawater
@ 2008-07-03 23:15 ` Michael Snyder
  2008-07-04  6:40   ` teawater
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Snyder @ 2008-07-03 23:15 UTC (permalink / raw)
  To: teawater; +Cc: gdb

On Mon, 2008-06-30 at 16:58 +0800, teawater wrote:
> target-descriptions.c has a memory leek in function
> maint_print_c_tdesc_cmd. char *function is xmalloc at line 1016.
> There are returns at the end of this function without calling free.
> And this variable is just used in this function. So I change it to
> "alloca".
> This patch is for the GDB cvs version.
> 
> 2008-06-21  Hui Zhu  <teawater@gmail.com>
>        * target-descriptions.c (maint_print_c_tdesc_cmd): Fix a memory leak.
> 
> --- a/gdb/target-descriptions.c
> +++ b/gdb/target-descriptions.c
> @@ -1013,7 +1013,7 @@ maint_print_c_tdesc_cmd (char *args, int
>      error (_("The current target description did not come from an XML file."));
> 
>    filename = lbasename (target_description_filename);
> -  function = xmalloc (strlen (filename) + 1);
> +  function = alloca (strlen (filename) + 1);
>    for (inp = filename, outp = function; *inp != '\0'; inp++)
>      if (*inp == '.')
>        break;

This looks right to me -- committed.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch]: Fix memory leak of target-descriptions.c
  2008-07-03 23:15 ` Michael Snyder
@ 2008-07-04  6:40   ` teawater
  0 siblings, 0 replies; 3+ messages in thread
From: teawater @ 2008-07-04  6:40 UTC (permalink / raw)
  To: Michael Snyder; +Cc: gdb

Michael, Thank you very much.

teawater

On Fri, Jul 4, 2008 at 07:15, Michael Snyder <msnyder@specifix.com> wrote:
> On Mon, 2008-06-30 at 16:58 +0800, teawater wrote:
>> target-descriptions.c has a memory leek in function
>> maint_print_c_tdesc_cmd. char *function is xmalloc at line 1016.
>> There are returns at the end of this function without calling free.
>> And this variable is just used in this function. So I change it to
>> "alloca".
>> This patch is for the GDB cvs version.
>>
>> 2008-06-21  Hui Zhu  <teawater@gmail.com>
>>        * target-descriptions.c (maint_print_c_tdesc_cmd): Fix a memory leak.
>>
>> --- a/gdb/target-descriptions.c
>> +++ b/gdb/target-descriptions.c
>> @@ -1013,7 +1013,7 @@ maint_print_c_tdesc_cmd (char *args, int
>>      error (_("The current target description did not come from an XML file."));
>>
>>    filename = lbasename (target_description_filename);
>> -  function = xmalloc (strlen (filename) + 1);
>> +  function = alloca (strlen (filename) + 1);
>>    for (inp = filename, outp = function; *inp != '\0'; inp++)
>>      if (*inp == '.')
>>        break;
>
> This looks right to me -- committed.
>
>
>
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-07-04  6:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-30  8:58 [patch]: Fix memory leak of target-descriptions.c teawater
2008-07-03 23:15 ` Michael Snyder
2008-07-04  6:40   ` teawater

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox