summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2008-04-16 11:20:03 +0300
committerPanu Matilainen <pmatilai@redhat.com>2008-04-16 11:20:03 +0300
commit9e7d602e85440dd79054dfc440aa14bba841a830 (patch)
tree69ea1ef96194e70d835bea7f8f611edb0fb87de1
parent36cbcd454eed7a4158f49cfa55e2f817d5e22bd9 (diff)
downloadrpm-9e7d602e85440dd79054dfc440aa14bba841a830.tar.gz
rpm-9e7d602e85440dd79054dfc440aa14bba841a830.tar.bz2
rpm-9e7d602e85440dd79054dfc440aa14bba841a830.zip
Plug a memleak from pgpHexStr() in showQueryPackage()
- fmd5 is only needed in a single place, move alloc+free there to avoid having to deal with the umphteen continue cases
-rw-r--r--lib/query.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/query.c b/lib/query.c
index bc5f6990a..e9401642c 100644
--- a/lib/query.c
+++ b/lib/query.c
@@ -149,7 +149,6 @@ int showQueryPackage(QVA_t qva, rpmts ts, Header h)
rpmfileState fstate;
rpm_off_t fsize;
const char * fn;
- char *fmd5;
const char * fuser;
const char * fgroup;
const char * flink;
@@ -163,7 +162,6 @@ int showQueryPackage(QVA_t qva, rpmts ts, Header h)
fstate = rpmfiFState(fi);
fsize = rpmfiFSize(fi);
fn = rpmfiFN(fi);
- fmd5 = pgpHexStr(rpmfiMD5(fi), rpmDigestLength(PGPHASHALGO_MD5));
fuser = rpmfiFUser(fi);
fgroup = rpmfiFGroup(fi);
flink = rpmfiFLink(fi);
@@ -208,10 +206,13 @@ int showQueryPackage(QVA_t qva, rpmts ts, Header h)
}
if (qva->qva_flags & QUERY_FOR_DUMPFILES) {
- char *add;
+ char *add, *fmd5;
+ fmd5 = pgpHexStr(rpmfiMD5(fi), rpmDigestLength(PGPHASHALGO_MD5));
+
rasprintf(&add, "%s %d %d %s 0%o ", fn, (int)fsize, fmtime, fmd5, fmode);
rstrcat(&buf, add);
free(add);
+ free(fmd5);
if (fuser && fgroup) {
rasprintf(&add, "%s %s", fuser, fgroup);
@@ -253,7 +254,6 @@ int showQueryPackage(QVA_t qva, rpmts ts, Header h)
}
}
free(buf);
- free(fmd5);
}
rc = 0;