diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2012-12-18 13:22:12 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2012-12-19 12:47:02 +0200 |
commit | 90e18d0edb587d26777983fb68168857631e559b (patch) | |
tree | a69bc7c6d5a7330fa5f71d1ffa9227f6e8ba08a1 | |
parent | 4365113d537f10ba5229264c9a8cab5d38dcd633 (diff) | |
download | rpm-90e18d0edb587d26777983fb68168857631e559b.tar.gz rpm-90e18d0edb587d26777983fb68168857631e559b.tar.bz2 rpm-90e18d0edb587d26777983fb68168857631e559b.zip |
Clean up fix grabData() error handling in callers
- grabData() only returns non-NULL on data length > 0, separately
checking for length only makes it look like a possible case when
its not. If it were, it'd be a memory leak.
(cherry picked from commit aa6af71d457be5d78252f23ea68322dcaf199e4e)
-rw-r--r-- | lib/header.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/header.c b/lib/header.c index 9a42567b5..0f00dff04 100644 --- a/lib/header.c +++ b/lib/header.c @@ -1406,7 +1406,7 @@ static int intAddEntry(Header h, rpmtd td) { indexEntry entry; rpm_data_t data; - int length; + int length = 0; /* Count must always be >= 1 for headerAddEntry. */ if (td->count <= 0) @@ -1417,9 +1417,8 @@ static int intAddEntry(Header h, rpmtd td) if (hdrchkData(td->count)) return 0; - length = 0; data = grabData(td->type, td->data, td->count, &length); - if (data == NULL || length <= 0) + if (data == NULL) return 0; /* Allocate more index space if necessary */ @@ -1639,16 +1638,15 @@ int headerMod(Header h, rpmtd td) indexEntry entry; rpm_data_t oldData; rpm_data_t data; - int length; + int length = 0; /* First find the tag */ entry = findEntry(h, td->tag, td->type); if (!entry) return 0; - length = 0; data = grabData(td->type, td->data, td->count, &length); - if (data == NULL || length <= 0) + if (data == NULL) return 0; /* make sure entry points to the first occurence of this tag */ |