diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2019-05-10 11:59:11 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2020-03-26 11:57:58 +0200 |
commit | 54ec98e696178dd017f00aad539a2013561621ea (patch) | |
tree | ecb5aead6e161df07446bbf10fb8f866aed93718 | |
parent | 233f125b34de7776f9fed5d748876784ed5fbca6 (diff) | |
download | rpm-54ec98e696178dd017f00aad539a2013561621ea.tar.gz |
Fix memleak in rpmfcApplyInternal() in standalone operation (eg rpmdeps)
When called in spec context, the package structs are properly freed
but in rpmdeps context, commit 49f2bb7d8fd91f2d8b22bf7128fd3defe4ed5434
only added a "dirty kludgery" to make it not blow up. This causes
the rpmds structures created in rpmfcApplyInternal() to leak memory.
Make freePackage() internally available and use it for freeing the
dummy struct too to fix.
(cherry picked from commit df4f6a20c3bbf0d319643c17fb16364f64a1b10a)
-rw-r--r-- | build/rpmbuild_internal.h | 6 | ||||
-rw-r--r-- | build/rpmfc.c | 4 | ||||
-rw-r--r-- | build/spec.c | 2 |
3 files changed, 9 insertions, 3 deletions
diff --git a/build/rpmbuild_internal.h b/build/rpmbuild_internal.h index bcd05b458..50b021a9e 100644 --- a/build/rpmbuild_internal.h +++ b/build/rpmbuild_internal.h @@ -365,6 +365,12 @@ rpmRC lookupPackage(rpmSpec spec, const char * name, int flag, RPM_GNUC_INTERNAL Package newPackage(const char *name, rpmstrPool pool, Package * pkglist); +/** \ingroup rpmbuild + * Free a package control structure. + * @param pkg package control structure + */ +RPM_GNUC_INTERNAL +Package freePackage(Package pkg); /** \ingroup rpmbuild * Return rpmds containing the dependencies of a given type diff --git a/build/rpmfc.c b/build/rpmfc.c index 2fbfc69ab..fde253b27 100644 --- a/build/rpmfc.c +++ b/build/rpmfc.c @@ -771,7 +771,7 @@ rpmfc rpmfcFree(rpmfc fc) free(fc->fattrs); free(fc->fcolor); free(fc->fcdictx); - free(fc->pkg); + freePackage(fc->pkg); argiFree(fc->fddictx); argiFree(fc->fddictn); argiFree(fc->ddictx); @@ -1376,7 +1376,7 @@ rpmRC rpmfcGenerateDepends(const rpmSpec spec, Package pkg) } fc = rpmfcCreate(spec->buildRoot, 0); - free(fc->pkg); + freePackage(fc->pkg); fc->pkg = pkg; fc->skipProv = !pkg->autoProv; fc->skipReq = !pkg->autoReq; diff --git a/build/spec.c b/build/spec.c index d01cbe0fc..a9808ba94 100644 --- a/build/spec.c +++ b/build/spec.c @@ -138,7 +138,7 @@ Package newPackage(const char *name, rpmstrPool pool, Package *pkglist) return p; } -static Package freePackage(Package pkg) +Package freePackage(Package pkg) { if (pkg == NULL) return NULL; |