diff options
author | Pierre Muller <muller@ics.u-strasbg.fr> | 2012-12-14 23:27:11 +0000 |
---|---|---|
committer | Pierre Muller <muller@ics.u-strasbg.fr> | 2012-12-14 23:27:11 +0000 |
commit | 00218d9abf06d5ae8388edc7c956276e6d35813c (patch) | |
tree | 14f5d56340d51e117047ea752dfe71b302e187c8 /gdb/solib-target.c | |
parent | 83e6d6fd3eff0f32e2d610bdda20242c72be4ab8 (diff) | |
download | gdb-00218d9abf06d5ae8388edc7c956276e6d35813c.tar.gz |
* solib-target.c (solib_target_current_sos): Remove 'const'
qualifier from type of library_document local variable to be
able to free it and avoid a memory leak.
Use cleanup chain to avoid leak even if exceptino is generated.
Diffstat (limited to 'gdb/solib-target.c')
-rw-r--r-- | gdb/solib-target.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/gdb/solib-target.c b/gdb/solib-target.c index 0f3f850a6e9..54b4855c2be 100644 --- a/gdb/solib-target.c +++ b/gdb/solib-target.c @@ -246,7 +246,8 @@ static struct so_list * solib_target_current_sos (void) { struct so_list *new_solib, *start = NULL, *last = NULL; - const char *library_document; + char *library_document; + struct cleanup *old_chain; VEC(lm_info_p) *library_list; struct lm_info *info; int ix; @@ -258,8 +259,15 @@ solib_target_current_sos (void) if (library_document == NULL) return NULL; + /* solib_target_parse_libraries may throw, so we use a cleanup. */ + old_chain = make_cleanup (xfree, library_document); + /* Parse the list. */ library_list = solib_target_parse_libraries (library_document); + + /* library_document string is not needed behind this point. */ + do_cleanups (old_chain); + if (library_list == NULL) return NULL; |