diff options
author | Stephane Carrez <stcarrez@nerim.fr> | 2000-11-25 09:16:22 +0000 |
---|---|---|
committer | Stephane Carrez <stcarrez@nerim.fr> | 2000-11-25 09:16:22 +0000 |
commit | 7c070881e4a395f2e803aef0254508ee7a9dda99 (patch) | |
tree | 345b88bcb3f82e6146c59f258902c77cbd2eeb84 /sim/common | |
parent | 077b8428ab2abe6e4c66216151c518c03467323c (diff) | |
download | gdb-7c070881e4a395f2e803aef0254508ee7a9dda99.zip gdb-7c070881e4a395f2e803aef0254508ee7a9dda99.tar.gz gdb-7c070881e4a395f2e803aef0254508ee7a9dda99.tar.bz2 |
Fix memory leak in sim_parse_args
Diffstat (limited to 'sim/common')
-rw-r--r-- | sim/common/ChangeLog | 5 | ||||
-rw-r--r-- | sim/common/sim-options.c | 21 |
2 files changed, 22 insertions, 4 deletions
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog index bc5a33c..831e274 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -1,3 +1,8 @@ +2000-11-24 Stephane Carrez <Stephane.Carrez@worldnet.fr> + + * sim-options.c (sim_parse_args): Free the memory used for + long_options, short_options, handlers, opt_cpu, orig_val. + 2000-11-20 Ben Elliston <bje@redhat.com> * cgen-ops.h (SUBBI): New macro. diff --git a/sim/common/sim-options.c b/sim/common/sim-options.c index 077019c..9ccc51d 100644 --- a/sim/common/sim-options.c +++ b/sim/common/sim-options.c @@ -499,6 +499,7 @@ sim_parse_args (sd, argv) const OPTION *opt; OPTION_HANDLER **handlers; sim_cpu **opt_cpu; + SIM_RC result = SIM_RC_OK; /* Count the number of arguments. */ for (argc = 0; argv[argc] != NULL; ++argc) @@ -579,7 +580,8 @@ sim_parse_args (sd, argv) if (opt->shortopt != 0) { sim_io_eprintf (sd, "internal error, short cpu specific option"); - return SIM_RC_FAIL; + result = SIM_RC_FAIL; + break; } if (opt->opt.name != NULL) { @@ -617,13 +619,24 @@ sim_parse_args (sd, argv) break; } if (optc == '?') - return SIM_RC_FAIL; + { + result = SIM_RC_FAIL; + break; + } if ((*handlers[optc]) (sd, opt_cpu[optc], orig_val[optc], optarg, 0/*!is_command*/) == SIM_RC_FAIL) - return SIM_RC_FAIL; + { + result = SIM_RC_FAIL; + break; + } } - return SIM_RC_OK; + zfree (long_options); + zfree (short_options); + zfree (handlers); + zfree (opt_cpu); + zfree (orig_val); + return result; } /* Utility of sim_print_help to print a list of option tables. */ |