summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2019-11-07 15:32:12 +0200
committerPanu Matilainen <pmatilai@redhat.com>2020-03-26 11:57:58 +0200
commit406b57de58d1ba55c9854893caa9305d7474029f (patch)
tree40ad319496d4f44a00adc2f57a7ed4e4c7f5b2e6
parent1834607ce22aef2cae4ad75d44c5a984d6bc9661 (diff)
downloadrpm-406b57de58d1ba55c9854893caa9305d7474029f.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) (cherry picked from commit 3a65abde579abc8331de59e5c99e5acc0cf96427)
-rw-r--r--build/parsePrep.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/build/parsePrep.c b/build/parsePrep.c
index c73f09e15..5454b7af2 100644
--- a/build/parsePrep.c
+++ b/build/parsePrep.c
@@ -275,7 +275,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;
@@ -303,7 +302,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 */
@@ -320,6 +319,7 @@ static int doSetupMacro(rpmSpec spec, const char *line)
appendLineStringBuf((arg == 'a' ? after : before), chptr);
free(chptr);
}
+ free(optArg);
}
if (arg < -1) {