summaryrefslogtreecommitdiff
path: root/rpmdb
diff options
context:
space:
mode:
authorJindrich Novy <jnovy@redhat.com>2008-04-28 13:40:56 +0200
committerJindrich Novy <jnovy@redhat.com>2008-04-28 13:43:08 +0200
commitc729f98edf54306501096b7f45c55ca1f96373f0 (patch)
tree4245d6da37e3d994b928bee730477ba6272aff72 /rpmdb
parent811e7be604bc5f557ed5f3b7c711cc2322438761 (diff)
downloadrpm-c729f98edf54306501096b7f45c55ca1f96373f0.tar.gz
rpm-c729f98edf54306501096b7f45c55ca1f96373f0.tar.bz2
rpm-c729f98edf54306501096b7f45c55ca1f96373f0.zip
Simplify dirName handling in rpmdbFindByFile()
Diffstat (limited to 'rpmdb')
-rw-r--r--rpmdb/rpmdb.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/rpmdb/rpmdb.c b/rpmdb/rpmdb.c
index 9b7380bb1..afb4535e1 100644
--- a/rpmdb/rpmdb.c
+++ b/rpmdb/rpmdb.c
@@ -1080,13 +1080,8 @@ static int rpmdbFindByFile(rpmdb db, const char * filespec,
if (filespec == NULL) return -2;
if ((baseName = strrchr(filespec, '/')) != NULL) {
- char * t;
- size_t len;
-
- len = baseName - filespec + 1;
- t = strncpy(alloca(len + 1), filespec, len);
- t[len] = '\0';
- dirName = t;
+ dirName = strncpy(xmalloc(len + 1), filespec, baseName - filespec + 1);
+ dirName[len] = '\0';
baseName++;
} else {
dirName = "";
@@ -1097,6 +1092,7 @@ static int rpmdbFindByFile(rpmdb db, const char * filespec,
fpc = fpCacheCreate(20);
fp1 = fpLookup(fpc, dirName, baseName, 1);
+ free(dirName);
dbi = dbiOpen(db, RPMTAG_BASENAMES, 0);
if (dbi != NULL) {