mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-05 06:23:58 +08:00
Fix erroneous cleanup use in add_solib_catchpoint
I happened to notice that add_solib_catchpoint allocated the new catchpoint with "new" but installed a cleanup using "xfree". This patch fixes the bug by changing the function to use std::unique_ptr instead. ChangeLog 2017-08-22 Tom Tromey <tom@tromey.com> * breakpoint.c (add_solib_catchpoint): Use std::unique_ptr.
This commit is contained in:
@ -1,3 +1,7 @@
|
|||||||
|
2017-08-22 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
|
* breakpoint.c (add_solib_catchpoint): Use std::unique_ptr.
|
||||||
|
|
||||||
2017-08-22 Tom Tromey <tom@tromey.com>
|
2017-08-22 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* psymtab.c (psymtab_search_name): Return a unique_xmalloc_ptr.
|
* psymtab.c (psymtab_search_name): Return a unique_xmalloc_ptr.
|
||||||
|
@ -8464,16 +8464,13 @@ static struct breakpoint_ops catch_solib_breakpoint_ops;
|
|||||||
void
|
void
|
||||||
add_solib_catchpoint (const char *arg, int is_load, int is_temp, int enabled)
|
add_solib_catchpoint (const char *arg, int is_load, int is_temp, int enabled)
|
||||||
{
|
{
|
||||||
struct solib_catchpoint *c;
|
|
||||||
struct gdbarch *gdbarch = get_current_arch ();
|
struct gdbarch *gdbarch = get_current_arch ();
|
||||||
struct cleanup *cleanup;
|
|
||||||
|
|
||||||
if (!arg)
|
if (!arg)
|
||||||
arg = "";
|
arg = "";
|
||||||
arg = skip_spaces_const (arg);
|
arg = skip_spaces_const (arg);
|
||||||
|
|
||||||
c = new solib_catchpoint ();
|
std::unique_ptr<solib_catchpoint> c (new solib_catchpoint ());
|
||||||
cleanup = make_cleanup (xfree, c);
|
|
||||||
|
|
||||||
if (*arg != '\0')
|
if (*arg != '\0')
|
||||||
{
|
{
|
||||||
@ -8483,13 +8480,12 @@ add_solib_catchpoint (const char *arg, int is_load, int is_temp, int enabled)
|
|||||||
}
|
}
|
||||||
|
|
||||||
c->is_load = is_load;
|
c->is_load = is_load;
|
||||||
init_catchpoint (c, gdbarch, is_temp, NULL,
|
init_catchpoint (c.get (), gdbarch, is_temp, NULL,
|
||||||
&catch_solib_breakpoint_ops);
|
&catch_solib_breakpoint_ops);
|
||||||
|
|
||||||
c->enable_state = enabled ? bp_enabled : bp_disabled;
|
c->enable_state = enabled ? bp_enabled : bp_disabled;
|
||||||
|
|
||||||
discard_cleanups (cleanup);
|
install_breakpoint (0, c.release (), 1);
|
||||||
install_breakpoint (0, c, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A helper function that does all the work for "catch load" and
|
/* A helper function that does all the work for "catch load" and
|
||||||
|
Reference in New Issue
Block a user