diff options
author | Andrew Cagney <cagney@redhat.com> | 2004-02-25 15:57:42 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 2004-02-25 15:57:42 +0000 |
commit | 4d2acc6562ea8a557c937f99945e6920ed3a85a6 (patch) | |
tree | bdf73de27560bd8847e3ffdf9419e5ddfd253221 /gdb/cli/cli-script.c | |
parent | 19b846f3d918cfadfb96d761a57a3a6b673809dd (diff) | |
download | gdb-4d2acc6562ea8a557c937f99945e6920ed3a85a6.zip gdb-4d2acc6562ea8a557c937f99945e6920ed3a85a6.tar.gz gdb-4d2acc6562ea8a557c937f99945e6920ed3a85a6.tar.bz2 |
2004-02-25 Andrew Cagney <cagney@redhat.com>
PR cli/1566. Problem found, and fix suggested by David Allan.
* cli/cli-script.c (execute_control_command): Unconditionally
install a cleanup. Default "ret" to "invalid_control". Use
"break" instead of "return" to escape from the switch.
Diffstat (limited to 'gdb/cli/cli-script.c')
-rw-r--r-- | gdb/cli/cli-script.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c index a8375a3..ca0c14f 100644 --- a/gdb/cli/cli-script.c +++ b/gdb/cli/cli-script.c @@ -294,21 +294,25 @@ execute_control_command (struct command_line *cmd) { struct expression *expr; struct command_line *current; - struct cleanup *old_chain = 0; + struct cleanup *old_chain = make_cleanup (null_cleanup, 0); struct value *val; struct value *val_mark; int loop; enum command_control_type ret; char *new_line; + /* Start by assuming failure, if a problem is detected, the code + below will simply "break" out of the switch. */ + ret = invalid_control; + switch (cmd->control_type) { case simple_control: /* A simple command, execute it and return. */ new_line = insert_args (cmd->line); if (!new_line) - return invalid_control; - old_chain = make_cleanup (free_current_contents, &new_line); + break; + make_cleanup (free_current_contents, &new_line); execute_command (new_line, 0); ret = cmd->control_type; break; @@ -325,8 +329,8 @@ execute_control_command (struct command_line *cmd) /* Parse the loop control expression for the while statement. */ new_line = insert_args (cmd->line); if (!new_line) - return invalid_control; - old_chain = make_cleanup (free_current_contents, &new_line); + break; + make_cleanup (free_current_contents, &new_line); expr = parse_expression (new_line); make_cleanup (free_current_contents, &expr); @@ -385,8 +389,8 @@ execute_control_command (struct command_line *cmd) { new_line = insert_args (cmd->line); if (!new_line) - return invalid_control; - old_chain = make_cleanup (free_current_contents, &new_line); + break; + make_cleanup (free_current_contents, &new_line); /* Parse the conditional for the if statement. */ expr = parse_expression (new_line); make_cleanup (free_current_contents, &expr); @@ -424,11 +428,10 @@ execute_control_command (struct command_line *cmd) default: warning ("Invalid control type in command structure."); - return invalid_control; + break; } - if (old_chain) - do_cleanups (old_chain); + do_cleanups (old_chain); return ret; } |