[rfa] add_symbol_file_command, avoid memory leak.

Michael Snyder
2011-02-27T01:38:11Z

[-- Attachment #1: Type: text/plain, Size: 114 bytes --]

This looks straightforward, but I'd appreciate review.
I don't really understand why sect_opts never gets freed?

[-- Attachment #2: symfile.txt --]
[-- Type: text/plain, Size: 938 bytes --]

2011-02-26 Michael Snyder <msnyder@vmware.com>

* symfile.c (add_symbol_file_command): Avoid memory leak.

Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.307
diff -u -p -u -p -r1.307 symfile.c
--- symfile.c 26 Feb 2011 02:07:09 -0000 1.307
+++ symfile.c 27 Feb 2011 01:35:32 -0000
@@ -2169,15 +2169,15 @@ add_symbol_file_command (char *args, int
size_t num_sect_opts = 0;
struct cleanup *my_cleanups = make_cleanup (null_cleanup, NULL);

+ if (args == NULL)
+ error (_("add-symbol-file takes a file name and an address"));
+
num_sect_opts = 16;
sect_opts = (struct sect_opt *) xmalloc (num_sect_opts
* sizeof (struct sect_opt));

dont_repeat ();

- if (args == NULL)
- error (_("add-symbol-file takes a file name and an address"));
-
argv = gdb_buildargv (args);
make_cleanup_freeargv (argv);