Date: Wed, 6 Dec 2017 21:18:45 +0000 (UTC) From: "Stephen J. Kiernan" <stevek@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r326636 - head/contrib/binutils/libiberty Message-ID: <201712062118.vB6LIjgL019389@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: stevek Date: Wed Dec 6 21:18:45 2017 New Revision: 326636 URL: https://svnweb.freebsd.org/changeset/base/326636 Log: The function make_relative_prefix_1 does not properly free locally allocated memory when it returns early. Free the memory associated with the variables full_programe, bin_dirs, prog_dirs, and prefix_dirs when the function returns early. Submitted by: Tom Rix <trix@juniper.net> Reviewed by: jhibbits, emaste Approved by: sjg (mentor) Obtained from: Juniper Networks, Inc. MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D9691 Modified: head/contrib/binutils/libiberty/make-relative-prefix.c Modified: head/contrib/binutils/libiberty/make-relative-prefix.c ============================================================================== --- head/contrib/binutils/libiberty/make-relative-prefix.c Wed Dec 6 21:12:24 2017 (r326635) +++ head/contrib/binutils/libiberty/make-relative-prefix.c Wed Dec 6 21:18:45 2017 (r326636) @@ -299,10 +299,18 @@ make_relative_prefix_1 (const char *progname, const ch full_progname = strdup(progname); prog_dirs = split_directories (full_progname, &prog_num); - bin_dirs = split_directories (bin_prefix, &bin_num); + if (prog_dirs == NULL) + { + free (full_progname); + return NULL; + } free (full_progname); - if (bin_dirs == NULL || 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--; @@ -365,7 +373,12 @@ make_relative_prefix_1 (const char *progname, const ch ret = (char *) malloc (needed_len); if (ret == NULL) - return NULL; + { + free_split_directories (prog_dirs); + free_split_directories (bin_dirs); + free_split_directories (prefix_dirs); + return NULL; + } /* Build up the pathnames in argv[0]. */ *ret = '\0';
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201712062118.vB6LIjgL019389>