mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-27 06:17:47 +08:00
gdb: Add cleanup to avoid memory leak on error.
Use cleanup to avoid leaking memory if an error occurs during tui start up. gdb/ChangeLog: * tui/tui-layout.c (tui_set_layout_for_display_command): Ensure buf_ptr is freed.
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
2015-05-21 Andrew Burgess <andrew.burgess@embecosm.com>
|
||||||
|
|
||||||
|
* tui/tui-layout.c (tui_set_layout_for_display_command): Ensure
|
||||||
|
buf_ptr is freed.
|
||||||
|
|
||||||
2015-05-21 Andrew Burgess <andrew.burgess@embecosm.com>
|
2015-05-21 Andrew Burgess <andrew.burgess@embecosm.com>
|
||||||
|
|
||||||
* tui/tui-layout.c (tui_layout_command): Move call to tui_enable
|
* tui/tui-layout.c (tui_layout_command): Move call to tui_enable
|
||||||
|
@ -409,10 +409,12 @@ tui_set_layout_by_name (const char *layout_name)
|
|||||||
char *buf_ptr;
|
char *buf_ptr;
|
||||||
enum tui_layout_type new_layout = UNDEFINED_LAYOUT;
|
enum tui_layout_type new_layout = UNDEFINED_LAYOUT;
|
||||||
enum tui_layout_type cur_layout = tui_current_layout ();
|
enum tui_layout_type cur_layout = tui_current_layout ();
|
||||||
|
struct cleanup *old_chain;
|
||||||
|
|
||||||
buf_ptr = (char *) xstrdup (layout_name);
|
buf_ptr = (char *) xstrdup (layout_name);
|
||||||
for (i = 0; (i < strlen (layout_name)); i++)
|
for (i = 0; (i < strlen (layout_name)); i++)
|
||||||
buf_ptr[i] = toupper (buf_ptr[i]);
|
buf_ptr[i] = toupper (buf_ptr[i]);
|
||||||
|
old_chain = make_cleanup (xfree, buf_ptr);
|
||||||
|
|
||||||
/* First check for ambiguous input. */
|
/* First check for ambiguous input. */
|
||||||
if (strlen (buf_ptr) <= 1 && *buf_ptr == 'S')
|
if (strlen (buf_ptr) <= 1 && *buf_ptr == 'S')
|
||||||
@ -450,7 +452,7 @@ tui_set_layout_by_name (const char *layout_name)
|
|||||||
tui_set_layout (new_layout);
|
tui_set_layout (new_layout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xfree (buf_ptr);
|
do_cleanups (old_chain);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
status = TUI_FAILURE;
|
status = TUI_FAILURE;
|
||||||
|
Reference in New Issue
Block a user