2007-08-04 Michael Snyder * solib.c (solib_open): Memory leak -- openp returns xmalloc buffer. Index: solib.c =================================================================== RCS file: /cvs/src/src/gdb/solib.c,v retrieving revision 1.94 diff -p -r1.94 solib.c *** solib.c 3 Jul 2007 12:14:43 -0000 1.94 --- solib.c 5 Aug 2007 03:13:49 -0000 *************** solib_open (char *in_pathname, char **fo *** 156,162 **** gdb_sysroot_is_empty = (gdb_sysroot == NULL || *gdb_sysroot == 0); if (! IS_ABSOLUTE_PATH (in_pathname) || gdb_sysroot_is_empty) ! temp_pathname = in_pathname; else { int prefix_len = strlen (gdb_sysroot); --- 156,162 ---- gdb_sysroot_is_empty = (gdb_sysroot == NULL || *gdb_sysroot == 0); if (! IS_ABSOLUTE_PATH (in_pathname) || gdb_sysroot_is_empty) ! temp_pathname = xstrdup (in_pathname); else { int prefix_len = strlen (gdb_sysroot); *************** solib_open (char *in_pathname, char **fo *** 167,173 **** prefix_len--; /* Cat the prefixed pathname together. */ ! temp_pathname = alloca (prefix_len + strlen (in_pathname) + 1); strncpy (temp_pathname, gdb_sysroot, prefix_len); temp_pathname[prefix_len] = '\0'; strcat (temp_pathname, in_pathname); --- 167,173 ---- prefix_len--; /* Cat the prefixed pathname together. */ ! temp_pathname = xmalloc (prefix_len + strlen (in_pathname) + 1); strncpy (temp_pathname, gdb_sysroot, prefix_len); temp_pathname[prefix_len] = '\0'; strcat (temp_pathname, in_pathname); *************** solib_open (char *in_pathname, char **fo *** 226,231 **** --- 226,233 ---- (optionally) found_pathname. */ if (found_pathname != NULL && temp_pathname != NULL) *found_pathname = xstrdup (temp_pathname); + + xfree (temp_pathname); return found_file; }