diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2011-05-24 14:07:12 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2011-05-24 14:07:12 +0300 |
commit | b5d54b35d4bc2745b73f4b75bdebed36abce7ed1 (patch) | |
tree | a7ca7fa105166d8c7f374c19f1960a4d4e2557e8 /lib/header.c | |
parent | f444e21be0bc644254c5f59310de3cbdbe924f1a (diff) | |
download | librpm-tizen-b5d54b35d4bc2745b73f4b75bdebed36abce7ed1.tar.gz librpm-tizen-b5d54b35d4bc2745b73f4b75bdebed36abce7ed1.tar.bz2 librpm-tizen-b5d54b35d4bc2745b73f4b75bdebed36abce7ed1.zip |
Handle HEADERFLAG_SORTED bit correctly in headerUnsort()
- Within rpm there's exactly one caller of headerUnsort() which has
kinda taken care of re-sorting the header on exit, but only if it
returns successfully, meaning the header sort status could've been
left in inconsistent state with implications on consequent
operations on that header. Also this is part of the public API
yet callers have no chance of adjusting the flag when they call it
(and why should they).
- Also dont bother sorting if the header is already in unsorted state.
Diffstat (limited to 'lib/header.c')
-rw-r--r-- | lib/header.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/header.c b/lib/header.c index a777f07b7..38cea37c4 100644 --- a/lib/header.c +++ b/lib/header.c @@ -247,7 +247,10 @@ static int offsetCmp(const void * avp, const void * bvp) */ void headerUnsort(Header h) { - qsort(h->index, h->indexUsed, sizeof(*h->index), offsetCmp); + if (h->flags & HEADERFLAG_SORTED) { + qsort(h->index, h->indexUsed, sizeof(*h->index), offsetCmp); + h->flags &= ~HEADERFLAG_SORTED; + } } unsigned headerSizeof(Header h, int magicp) @@ -696,7 +699,6 @@ static void * doHeaderUnload(Header h, if (lengthPtr) *lengthPtr = len; - h->flags &= ~HEADERFLAG_SORTED; headerSort(h); return (void *) ei; |