depends.c (dbSatisfiesDepend): strdup dbProvCache keys (ALT#23811)

My previous assumption that strdup() was not needed for dbProvCache keys
was wrong.  The keys point to header memory, which is right.  However,
those are not only ts->addedPackages and ts->erasedPackages headers.
In checkDependent(), headers come from rpmdb and are disposed immediately
after the check.
This commit is contained in:
Alexey Tourbin 2010-08-05 17:58:49 +04:00
parent cb105c88c8
commit c9b1f0e2ec

View File

@ -525,8 +525,7 @@ int dbSatisfiesDepend(rpmTransactionSet ts,
/* Update dbProvCache.
* When versions did not match, it is still okay to say "yes" for the name. */
if (cacheData == NULL)
/* XXX keyName points to header memory, no need for strdup */
htAddEntry(dbProvCache, keyName, rc < 1 ? "yes" : NULL);
htAddEntry(dbProvCache, xstrdup(keyName), rc < 1 ? "yes" : NULL);
return rc ? 1 : 0;
}
@ -901,6 +900,6 @@ int rpmdepCheck(rpmTransactionSet ts,
exit:
ps->problems = _free(ps->problems);
ps = _free(ps);
dbProvCache = htFree(dbProvCache, NULL, NULL);
dbProvCache = htFree(dbProvCache, _free, NULL);
return rc;
}