This is the mail archive of the gdb@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]

[patch]: Fix memory leak of target-descriptions.c


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;


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