|
Panu Matilainen |
b6a0b1 |
diff --git a/lib/fprint.c b/lib/fprint.c
|
|
Panu Matilainen |
b6a0b1 |
index e57ba20..c56b0e5 100644
|
|
Panu Matilainen |
b6a0b1 |
--- a/lib/fprint.c
|
|
Panu Matilainen |
b6a0b1 |
+++ b/lib/fprint.c
|
|
Panu Matilainen |
b6a0b1 |
@@ -37,8 +37,10 @@ fingerPrintCache fpCacheCreate(int sizeHint)
|
|
Panu Matilainen |
b6a0b1 |
|
|
Panu Matilainen |
b6a0b1 |
fingerPrintCache fpCacheFree(fingerPrintCache cache)
|
|
Panu Matilainen |
b6a0b1 |
{
|
|
Panu Matilainen |
b6a0b1 |
- cache->ht = rpmFpEntryHashFree(cache->ht);
|
|
Panu Matilainen |
b6a0b1 |
- free(cache);
|
|
Panu Matilainen |
b6a0b1 |
+ if (cache) {
|
|
Panu Matilainen |
b6a0b1 |
+ cache->ht = rpmFpEntryHashFree(cache->ht);
|
|
Panu Matilainen |
b6a0b1 |
+ free(cache);
|
|
Panu Matilainen |
b6a0b1 |
+ }
|
|
Panu Matilainen |
b6a0b1 |
return NULL;
|
|
Panu Matilainen |
b6a0b1 |
}
|
|
Panu Matilainen |
b6a0b1 |
|
|
Panu Matilainen |
b6a0b1 |
diff --git a/lib/rpmdb.c b/lib/rpmdb.c
|
|
Panu Matilainen |
b6a0b1 |
index 439a974..d76630e 100644
|
|
Panu Matilainen |
b6a0b1 |
--- a/lib/rpmdb.c
|
|
Panu Matilainen |
b6a0b1 |
+++ b/lib/rpmdb.c
|
|
Panu Matilainen |
b6a0b1 |
@@ -1098,20 +1098,20 @@ int rpmdbVerify(const char * prefix)
|
|
Panu Matilainen |
b6a0b1 |
static int rpmdbFindByFile(rpmdb db, const char * filespec,
|
|
Panu Matilainen |
b6a0b1 |
DBT * key, DBT * data, dbiIndexSet * matches)
|
|
Panu Matilainen |
b6a0b1 |
{
|
|
Panu Matilainen |
b6a0b1 |
- char * dirName;
|
|
Panu Matilainen |
b6a0b1 |
+ char * dirName = NULL;
|
|
Panu Matilainen |
b6a0b1 |
const char * baseName;
|
|
Panu Matilainen |
b6a0b1 |
- fingerPrintCache fpc;
|
|
Panu Matilainen |
b6a0b1 |
+ fingerPrintCache fpc = NULL;
|
|
Panu Matilainen |
b6a0b1 |
fingerPrint fp1;
|
|
Panu Matilainen |
b6a0b1 |
dbiIndex dbi = NULL;
|
|
Panu Matilainen |
b6a0b1 |
DBC * dbcursor;
|
|
Panu Matilainen |
b6a0b1 |
dbiIndexSet allMatches = NULL;
|
|
Panu Matilainen |
b6a0b1 |
dbiIndexItem rec = NULL;
|
|
Panu Matilainen |
b6a0b1 |
unsigned int i;
|
|
Panu Matilainen |
b6a0b1 |
- int rc;
|
|
Panu Matilainen |
b6a0b1 |
+ int rc = -2; /* assume error */
|
|
Panu Matilainen |
b6a0b1 |
int xx;
|
|
Panu Matilainen |
b6a0b1 |
|
|
Panu Matilainen |
b6a0b1 |
*matches = NULL;
|
|
Panu Matilainen |
b6a0b1 |
- if (filespec == NULL) return -2;
|
|
Panu Matilainen |
b6a0b1 |
+ if (filespec == NULL) return rc; /* nothing alloced yet */
|
|
Panu Matilainen |
b6a0b1 |
|
|
Panu Matilainen |
b6a0b1 |
if ((baseName = strrchr(filespec, '/')) != NULL) {
|
|
Panu Matilainen |
b6a0b1 |
size_t len = baseName - filespec + 1;
|
|
Panu Matilainen |
b6a0b1 |
@@ -1123,11 +1123,7 @@ static int rpmdbFindByFile(rpmdb db, const char * filespec,
|
|
Panu Matilainen |
b6a0b1 |
baseName = filespec;
|
|
Panu Matilainen |
b6a0b1 |
}
|
|
Panu Matilainen |
b6a0b1 |
if (baseName == NULL)
|
|
Panu Matilainen |
b6a0b1 |
- return -2;
|
|
Panu Matilainen |
b6a0b1 |
-
|
|
Panu Matilainen |
b6a0b1 |
- fpc = fpCacheCreate(20);
|
|
Panu Matilainen |
b6a0b1 |
- fp1 = fpLookup(fpc, dirName, baseName, 1);
|
|
Panu Matilainen |
b6a0b1 |
- free(dirName);
|
|
Panu Matilainen |
b6a0b1 |
+ goto exit;
|
|
Panu Matilainen |
b6a0b1 |
|
|
Panu Matilainen |
b6a0b1 |
dbi = dbiOpen(db, RPMTAG_BASENAMES, 0);
|
|
Panu Matilainen |
b6a0b1 |
if (dbi != NULL) {
|
|
Panu Matilainen |
b6a0b1 |
@@ -1154,16 +1150,14 @@ static int rpmdbFindByFile(rpmdb db, const char * filespec,
|
|
Panu Matilainen |
b6a0b1 |
} else
|
|
Panu Matilainen |
b6a0b1 |
rc = -2;
|
|
Panu Matilainen |
b6a0b1 |
|
|
Panu Matilainen |
b6a0b1 |
- if (rc) {
|
|
Panu Matilainen |
b6a0b1 |
- allMatches = dbiFreeIndexSet(allMatches);
|
|
Panu Matilainen |
b6a0b1 |
- fpc = fpCacheFree(fpc);
|
|
Panu Matilainen |
b6a0b1 |
- return rc;
|
|
Panu Matilainen |
b6a0b1 |
- }
|
|
Panu Matilainen |
b6a0b1 |
+ if (rc || allMatches == NULL) goto exit;
|
|
Panu Matilainen |
b6a0b1 |
|
|
Panu Matilainen |
b6a0b1 |
*matches = xcalloc(1, sizeof(**matches));
|
|
Panu Matilainen |
b6a0b1 |
rec = dbiIndexNewItem(0, 0);
|
|
Panu Matilainen |
b6a0b1 |
+ fpc = fpCacheCreate(allMatches->count);
|
|
Panu Matilainen |
b6a0b1 |
+ fp1 = fpLookup(fpc, dirName, baseName, 1);
|
|
Panu Matilainen |
b6a0b1 |
+
|
|
Panu Matilainen |
b6a0b1 |
i = 0;
|
|
Panu Matilainen |
b6a0b1 |
- if (allMatches != NULL)
|
|
Panu Matilainen |
b6a0b1 |
while (i < allMatches->count) {
|
|
Panu Matilainen |
b6a0b1 |
struct rpmtd_s bn, dn, di;
|
|
Panu Matilainen |
b6a0b1 |
const char ** baseNames, ** dirNames;
|
|
Panu Matilainen |
b6a0b1 |
@@ -1216,16 +1210,19 @@ static int rpmdbFindByFile(rpmdb db, const char * filespec,
|
|
Panu Matilainen |
b6a0b1 |
}
|
|
Panu Matilainen |
b6a0b1 |
|
|
Panu Matilainen |
b6a0b1 |
rec = _free(rec);
|
|
Panu Matilainen |
b6a0b1 |
- allMatches = dbiFreeIndexSet(allMatches);
|
|
Panu Matilainen |
b6a0b1 |
-
|
|
Panu Matilainen |
b6a0b1 |
- fpc = fpCacheFree(fpc);
|
|
Panu Matilainen |
b6a0b1 |
+ fpCacheFree(fpc);
|
|
Panu Matilainen |
b6a0b1 |
|
|
Panu Matilainen |
b6a0b1 |
if ((*matches)->count == 0) {
|
|
Panu Matilainen |
b6a0b1 |
*matches = dbiFreeIndexSet(*matches);
|
|
Panu Matilainen |
b6a0b1 |
- return 1;
|
|
Panu Matilainen |
b6a0b1 |
+ rc = 1;
|
|
Panu Matilainen |
b6a0b1 |
+ } else {
|
|
Panu Matilainen |
b6a0b1 |
+ rc = 0;
|
|
Panu Matilainen |
b6a0b1 |
}
|
|
Panu Matilainen |
b6a0b1 |
|
|
Panu Matilainen |
b6a0b1 |
- return 0;
|
|
Panu Matilainen |
b6a0b1 |
+exit:
|
|
Panu Matilainen |
b6a0b1 |
+ dbiFreeIndexSet(allMatches);
|
|
Panu Matilainen |
b6a0b1 |
+ free(dirName);
|
|
Panu Matilainen |
b6a0b1 |
+ return rc;
|
|
Panu Matilainen |
b6a0b1 |
}
|
|
Panu Matilainen |
b6a0b1 |
|
|
Panu Matilainen |
b6a0b1 |
/* XXX python/upgrade.c, install.c, uninstall.c */
|