diff options
author | Ayush Mittal <ayush.m@samsung.com> | 2021-02-18 21:59:03 -0700 |
---|---|---|
committer | Jeff Law <law@redhat.com> | 2021-02-18 22:00:06 -0700 |
commit | 0b2b7ef3676920c120d9b329e5b65924650ab44c (patch) | |
tree | 72664f00635506847ca548af99a9f4172b704983 | |
parent | d909ead68214042e9876a8df136d0835273d4b86 (diff) | |
download | gcc-0b2b7ef3676920c120d9b329e5b65924650ab44c.zip gcc-0b2b7ef3676920c120d9b329e5b65924650ab44c.tar.gz gcc-0b2b7ef3676920c120d9b329e5b65924650ab44c.tar.bz2 |
[PATCH v2] libiberty(argv.c): Fix memory leak in expandargv
libiberty:
* argv.c (expandargv): free allocated buffer if read fails.
-rw-r--r-- | libiberty/argv.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libiberty/argv.c b/libiberty/argv.c index cd97f90..48dcd10 100644 --- a/libiberty/argv.c +++ b/libiberty/argv.c @@ -442,7 +442,10 @@ expandargv (int *argcp, char ***argvp) due to CR/LF->CR translation when reading text files. That does not in-and-of itself indicate failure. */ && ferror (f)) - goto error; + { + free (buffer); + goto error; + } /* Add a NUL terminator. */ buffer[len] = '\0'; /* If the file is empty or contains only whitespace, buildargv would |