diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2019-11-07 15:32:12 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2019-11-18 12:46:29 +0200 |
commit | 3a65abde579abc8331de59e5c99e5acc0cf96427 (patch) | |
tree | 71f5a7bcfef5aec8a850df953d2b1ab1f5f1a043 | |
parent | c0fbb408068b5e2757971f32338690365eb0933f (diff) | |
download | rpm-3a65abde579abc8331de59e5c99e5acc0cf96427.tar.gz |
Fix ancient memleak on %setup arguments
poptGetOptArg() returns malloced strings and caller needs to free.
This will still leak on error paths but at least normal use is covered.
(cherry picked from commit af73aba20f856de3ebc9751166a2364e795b199d)
-rw-r--r-- | build/parsePrep.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/build/parsePrep.c b/build/parsePrep.c index 8dee3134f..fe37575e6 100644 --- a/build/parsePrep.c +++ b/build/parsePrep.c @@ -236,7 +236,6 @@ static int doSetupMacro(rpmSpec spec, const char *line) int argc; const char ** argv = NULL; int arg; - const char * optArg; int xx; rpmRC rc = RPMRC_FAIL; uint32_t num; @@ -264,7 +263,7 @@ static int doSetupMacro(rpmSpec spec, const char *line) optCon = poptGetContext(NULL, argc, argv, optionsTable, 0); while ((arg = poptGetNextOpt(optCon)) > 0) { - optArg = poptGetOptArg(optCon); + char *optArg = poptGetOptArg(optCon); /* We only parse -a and -b here */ @@ -281,6 +280,7 @@ static int doSetupMacro(rpmSpec spec, const char *line) appendLineStringBuf((arg == 'a' ? after : before), chptr); free(chptr); } + free(optArg); } if (arg < -1) { |