[PATCH 14/40] fix two buglets in breakpoint.c

Tom Tromey
2013-05-09T18:51:23Z

First, output_thread_groups leaks a cleanup along one return path.

Second, parse_cmd_to_aexpr could return without running its cleanups,
if there was an exception in a TRY_CATCH.

* breakpoint.c (output_thread_groups): Call do_cleanups along
all return paths.
(parse_cmd_to_aexpr): Call do_cleanups earlier.
---
gdb/breakpoint.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index f4f9325..56398a0 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -2248,6 +2248,8 @@ parse_cmd_to_aexpr (CORE_ADDR scope, char *cmd)
fpieces, nargs, argvec);
}

+ do_cleanups (old_cleanups);
+
if (ex.reason < 0)
{
/* If we got here, it means the command could not be parsed to a valid
@@ -2256,8 +2258,6 @@ parse_cmd_to_aexpr (CORE_ADDR scope, char *cmd)
return NULL;
}

- do_cleanups (old_cleanups);
-
/* We have a valid agent expression, return it. */
return aexpr;
}
@@ -5814,7 +5814,10 @@ output_thread_groups (struct ui_out *uiout,
/* For backward compatibility, don't display inferiors in CLI unless
there are several. Always display them for MI. */
if (!is_mi && mi_only)
- return;
+ {
+ do_cleanups (back_to);
+ return;
+ }

for (i = 0; VEC_iterate (int, inf_num, i, inf); ++i)
{
--
1.8.1.4