summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2009-03-10 10:17:13 +0200
committerPanu Matilainen <pmatilai@redhat.com>2009-04-16 15:15:00 +0300
commit8ff274f963947a9886b2ab8d119cd933edbb86d8 (patch)
tree2f1d6c592eef933552b30a95ff67bdf05c2f8e1c
parentcdb64dac0bd7ea51f869143cd024c2ce4ef07e59 (diff)
downloadrpm-8ff274f963947a9886b2ab8d119cd933edbb86d8.tar.gz
Don't return data from headerGet() on regionSwab() failure
- callers dont expect to free data if headerGet() returns failure, leaking memory (cherry picked from commit 65f3e55d3592da8fb482b5344a28013029199115)
-rw-r--r--lib/header.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/header.c b/lib/header.c
index fb9602be5..9455fc3d4 100644
--- a/lib/header.c
+++ b/lib/header.c
@@ -1179,6 +1179,10 @@ static int copyTdEntry(const indexEntry entry, rpmtd td, headerGetFlags flags)
dataStart = (unsigned char *) memcpy(pe + ril, dataStart, rdl);
rc = regionSwab(NULL, ril, 0, pe, dataStart, dataStart + rdl, 0);
+ /* don't return data on failure */
+ if (rc < 0) {
+ td->data = _free(td->data);
+ }
/* XXX 1 on success. */
rc = (rc < 0) ? 0 : 1;
} else {