diff options
author | Tom Tromey <tom@tromey.com> | 2018-05-26 23:26:39 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2018-07-17 13:21:47 -0600 |
commit | a1a31cb8dce7d1bfa7878dc08c28af330ef2ed69 (patch) | |
tree | 7819771634fdc0ad4ef245800c3b354abf6382e4 /gdb/guile/guile.c | |
parent | 15bf30027bcb167833a0ca2c619c03f177ef1ba4 (diff) | |
download | gdb-a1a31cb8dce7d1bfa7878dc08c28af330ef2ed69.zip gdb-a1a31cb8dce7d1bfa7878dc08c28af330ef2ed69.tar.gz gdb-a1a31cb8dce7d1bfa7878dc08c28af330ef2ed69.tar.bz2 |
Return unique_xmalloc_ptr from gdbscm_safe_eval_string
This changes gdbscm_safe_eval_string to return a unique_xmalloc_ptr.
This allows for the removal of some cleanups. It also fixes a
potential latent memory leak in gdbscm_set_backtrace.
gdb/ChangeLog
2018-07-17 Tom Tromey <tom@tromey.com>
* guile/guile.c (gdbscm_eval_from_control_command): Update.
* guile/guile-internal.h (gdbscm_safe_eval_string): Update.
* guile/scm-objfile.c (gdbscm_execute_objfile_script): Update.
* guile/scm-safe-call.c (gdbscm_safe_eval_string): Return
unique_xmalloc_ptr.
Diffstat (limited to 'gdb/guile/guile.c')
-rw-r--r-- | gdb/guile/guile.c | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/gdb/guile/guile.c b/gdb/guile/guile.c index 0bbbf6e..6b5faa3 100644 --- a/gdb/guile/guile.c +++ b/gdb/guile/guile.c @@ -197,15 +197,10 @@ guile_command (const char *arg, int from_tty) if (arg && *arg) { - char *msg = gdbscm_safe_eval_string (arg, 1); + gdb::unique_xmalloc_ptr<char> msg = gdbscm_safe_eval_string (arg, 1); if (msg != NULL) - { - /* It is ok that this is a "dangling cleanup" because we - throw immediately. */ - make_cleanup (xfree, msg); - error ("%s", msg); - } + error ("%s", msg.get ()); } else { @@ -253,24 +248,16 @@ static void gdbscm_eval_from_control_command (const struct extension_language_defn *extlang, struct command_line *cmd) { - char *script, *msg; - struct cleanup *cleanup; + char *script; if (cmd->body_list_1 != nullptr) error (_("Invalid \"guile\" block structure.")); - cleanup = make_cleanup (null_cleanup, NULL); - script = compute_scheme_string (cmd->body_list_0.get ()); - msg = gdbscm_safe_eval_string (script, 0); + gdb::unique_xmalloc_ptr<char> msg = gdbscm_safe_eval_string (script, 0); xfree (script); if (msg != NULL) - { - make_cleanup (xfree, msg); - error ("%s", msg); - } - - do_cleanups (cleanup); + error ("%s", msg.get ()); } /* Read a file as Scheme code. |