[2/3] Fix leak in solib-target.c:library_list_start_library

Message ID 20181214191242.21560-3-palves@redhat.com
State New
Headers show
Series
  • Fix a few leaks found by Coverity
Related show

Commit Message

Pedro Alves Dec. 14, 2018, 7:12 p.m.
lm_info_target::name is nowadays std::string, so we're leaking the
result of xstrdup.

gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <palves@redhat.com>

	* solib-target.c (library_list_start_library): Don't xstrdup name.
---
 gdb/solib-target.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

-- 
2.14.4

Comments

Simon Marchi Dec. 14, 2018, 10:30 p.m. | #1
On 2018-12-14 14:12, Pedro Alves wrote:
> lm_info_target::name is nowadays std::string, so we're leaking the

> result of xstrdup.


Oops.  LGTM.

Thanks,

Simon

Patch

diff --git a/gdb/solib-target.c b/gdb/solib-target.c
index 3c9872c116..6a395ad378 100644
--- a/gdb/solib-target.c
+++ b/gdb/solib-target.c
@@ -124,10 +124,9 @@  library_list_start_library (struct gdb_xml_parser *parser,
 {
   VEC(lm_info_target_p) **list = (VEC(lm_info_target_p) **) user_data;
   lm_info_target *item = new lm_info_target;
-  const char *name
+  item->name
     = (const char *) xml_find_attribute (attributes, "name")->value.get ();
 
-  item->name = xstrdup (name);
   VEC_safe_push (lm_info_target_p, *list, item);
 }