diff options
Diffstat (limited to 'lib/rpmdb.c')
-rw-r--r-- | lib/rpmdb.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/lib/rpmdb.c b/lib/rpmdb.c index 41ee92c70..211a28981 100644 --- a/lib/rpmdb.c +++ b/lib/rpmdb.c @@ -1949,7 +1949,7 @@ int rpmdbAppendIterator(rpmdbMatchIterator mi, const int * hdrNums, int nHdrNums rpmdbMatchIterator rpmdbInitIterator(rpmdb db, rpmTag rpmtag, const void * keyp, size_t keylen) { - rpmdbMatchIterator mi; + rpmdbMatchIterator mi = NULL; dbiIndexSet set = NULL; dbiIndex dbi; void * mi_keyp = NULL; @@ -1970,11 +1970,6 @@ rpmdbMatchIterator rpmdbInitIterator(rpmdb db, rpmTag rpmtag, if (dbi == NULL) return NULL; - /* Chain cursors for teardown on abnormal exit. */ - mi = xcalloc(1, sizeof(*mi)); - mi->mi_next = rpmmiRock; - rpmmiRock = mi; - /* * Handle label and file name special cases. * Otherwise, retrieve join keys for secondary lookup. @@ -2022,10 +2017,7 @@ rpmdbMatchIterator rpmdbInitIterator(rpmdb db, rpmTag rpmtag, } if (rc) { /* error/not found */ set = dbiFreeIndexSet(set); - rpmmiRock = mi->mi_next; - mi->mi_next = NULL; - mi = _free(mi); - return NULL; + goto exit; } } @@ -2054,14 +2046,18 @@ rpmdbMatchIterator rpmdbInitIterator(rpmdb db, rpmTag rpmtag, } } + mi = xcalloc(1, sizeof(*mi)); mi->mi_keyp = mi_keyp; mi->mi_keylen = keylen; - + mi->mi_set = set; mi->mi_db = rpmdbLink(db); mi->mi_rpmtag = rpmtag; + /* Chain cursors for teardown on abnormal exit. */ + mi->mi_next = rpmmiRock; + rpmmiRock = mi; + mi->mi_dbc = NULL; - mi->mi_set = set; mi->mi_setx = 0; mi->mi_h = NULL; mi->mi_sorted = 0; @@ -2076,6 +2072,7 @@ rpmdbMatchIterator rpmdbInitIterator(rpmdb db, rpmTag rpmtag, mi->mi_ts = NULL; mi->mi_hdrchk = NULL; +exit: return mi; } |