2007-08-09 Michael Snyder <msnyder@access-company.com>
authorMichael Snyder <msnyder@vmware.com>
Thu, 9 Aug 2007 18:37:08 +0000 (18:37 +0000)
committerMichael Snyder <msnyder@vmware.com>
Thu, 9 Aug 2007 18:37:08 +0000 (18:37 +0000)
* solib.c (solib_open): Memory leak -- openp returns xmalloc buffer.

gdb/ChangeLog
gdb/solib.c

index f83e0403daecce4f5304925b9600bcfd783855e0..0eadaed2aeaa755d0fcf81af179bc659805ee2f9 100644 (file)
@@ -1,3 +1,7 @@
+2007-08-09  Michael Snyder  <msnyder@access-company.com>
+
+       * solib.c (solib_open): Memory leak -- openp returns xmalloc buffer.
+
 2007-08-09  Joel Brobecker  <brobecker@adacore.com>
 
         * solib-som.c (som_relocate_section_addresses): Stop saving
index f522812d427930b9a9341920d64e76500347ce30..bd4cf5175517cd9203ff7a6195cf1497ee6ec019 100644 (file)
@@ -176,6 +176,17 @@ solib_open (char *in_pathname, char **found_pathname)
   /* Now see if we can open it.  */
   found_file = open (temp_pathname, O_RDONLY | O_BINARY, 0);
 
+  /* We try to find the library in various ways.  After each attempt
+     (except for the one above), either found_file >= 0 and
+     temp_pathname is a malloc'd string, or found_file < 0 and
+     temp_pathname does not point to storage that needs to be
+     freed.  */
+
+    if (found_file < 0)
+      temp_pathname = NULL;
+    else
+      temp_pathname = xstrdup (temp_pathname);
+
   /* If the search in gdb_sysroot failed, and the path name is
      absolute at this point, make it relative.  (openp will try and open the
      file according to its absolute path otherwise, which is not what we want.)
@@ -224,8 +235,13 @@ solib_open (char *in_pathname, char **found_pathname)
 
   /* Done.  If not found, tough luck.  Return found_file and 
      (optionally) found_pathname.  */
-  if (found_pathname != NULL && temp_pathname != NULL)
-    *found_pathname = xstrdup (temp_pathname);
+  if (temp_pathname)
+    {
+      if (found_pathname != NULL)
+       *found_pathname = temp_pathname;
+      else
+       xfree (temp_pathname);
+    }
   return found_file;
 }
 
This page took 0.029059 seconds and 4 git commands to generate.