From: DJ Delorie Date: Fri, 3 Aug 2007 19:49:44 +0000 (+0000) Subject: merge from gcc X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9250f7f0d29e4d4a5d40b2c77daa78d9438d7ead;p=binutils-gdb.git merge from gcc --- diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index aee3cc76f57..28e2c4fab3a 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,8 @@ +2007-08-03 Michael Snyder + + * make-relative-prefix.c (make_relative_prefix_1): Fix resource + leak. + 2007-07-31 Michael Snyder * cp-demangle.c (d_print_comp): Guard against null. diff --git a/libiberty/make-relative-prefix.c b/libiberty/make-relative-prefix.c index 037809e34ed..be61040e18c 100644 --- a/libiberty/make-relative-prefix.c +++ b/libiberty/make-relative-prefix.c @@ -299,11 +299,17 @@ make_relative_prefix_1 (const char *progname, const char *bin_prefix, full_progname = strdup(progname); prog_dirs = split_directories (full_progname, &prog_num); - bin_dirs = split_directories (bin_prefix, &bin_num); free (full_progname); - if (bin_dirs == NULL || prog_dirs == NULL) + if (prog_dirs == NULL) return NULL; + bin_dirs = split_directories (bin_prefix, &bin_num); + if (bin_dirs == NULL) + { + free_split_directories (prog_dirs); + return NULL; + } + /* Remove the program name from comparison of directory names. */ prog_num--;