From: Pierre Muller Date: Fri, 14 Dec 2012 23:27:13 +0000 (+0000) Subject: * solib-target.c (solib_target_current_sos): Remove 'const' X-Git-Tag: cgen-snapshot-20130101~103 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b25d79d436158060439a2ba989acc84259f3a369;p=external%2Fbinutils.git * 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. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 19cdae4..07119af 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2012-12-14 Pierre Muller + Pedro Alves + + * 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. + 2012-12-14 Tom Tromey PR c++/8888: diff --git a/gdb/solib-target.c b/gdb/solib-target.c index 0f3f850..54b4855 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;