[Ada] Fix cleanup leak in ada-lang.c:old_renaming_is_invisible
authorJoel Brobecker <brobecker@gnat.com>
Tue, 21 May 2013 05:41:31 +0000 (05:41 +0000)
committerJoel Brobecker <brobecker@gnat.com>
Tue, 21 May 2013 05:41:31 +0000 (05:41 +0000)
gdb/ChangeLog:

* ada-lang.c (old_renaming_is_invisible): Fix cleanup leak.

gdb/ChangeLog
gdb/ada-lang.c

index 19a4cd6d2c8a65beca8184e35847cf6685554d0a..c48f7e7d50bc4b6544c4dee886d17dca2f56d8db 100644 (file)
@@ -1,3 +1,7 @@
+2013-05-21  Joel Brobecker  <brobecker@adacore.com>
+
+       * ada-lang.c (old_renaming_is_invisible): Fix cleanup leak.
+
 2013-05-21  Hui Zhu  <hui@codesourcery.com>
 
        * breakpoint.c (dprintf_breakpoint_ops): Remove its static.
index fa6db0f7411eb78479ac2f8ce9498f090f332215..b6d5e0b71a5732afeb34122332b82d96ee75f1aa 100644 (file)
@@ -4726,17 +4726,20 @@ static int
 old_renaming_is_invisible (const struct symbol *sym, const char *function_name)
 {
   char *scope;
+  struct cleanup *old_chain;
 
   if (SYMBOL_CLASS (sym) != LOC_TYPEDEF)
     return 0;
 
   scope = xget_renaming_scope (SYMBOL_TYPE (sym));
-
-  make_cleanup (xfree, scope);
+  old_chain = make_cleanup (xfree, scope);
 
   /* If the rename has been defined in a package, then it is visible.  */
   if (is_package_name (scope))
-    return 0;
+    {
+      do_cleanups (old_chain);
+      return 0;
+    }
 
   /* Check that the rename is in the current function scope by checking
      that its name starts with SCOPE.  */
@@ -4748,7 +4751,12 @@ old_renaming_is_invisible (const struct symbol *sym, const char *function_name)
   if (strncmp (function_name, "_ada_", 5) == 0)
     function_name += 5;
 
-  return (strncmp (function_name, scope, strlen (scope)) != 0);
+  {
+    int is_invisible = strncmp (function_name, scope, strlen (scope)) != 0;
+
+    do_cleanups (old_chain);
+    return is_invisible;
+  }
 }
 
 /* Remove entries from SYMS that corresponds to a renaming entity that
This page took 0.04014 seconds and 4 git commands to generate.