fix: memory leaks in rpmRunTransactions plugged.

CVS patchset: 2844
CVS date: 1999/02/28 18:36:19
This commit is contained in:
jbj 1999-02-28 18:36:19 +00:00
parent f5c1c639b8
commit c871d58f38
5 changed files with 82 additions and 56 deletions

View File

@ -1,4 +1,7 @@
2.91 -> 2.92
2.90 -> 2.91
- fix: memory leaks in rpmRunTransactions plugged.
- fix: build of packages w/o BuildRoot segfault.
- permit substitution of I18N strings from PO meta-catalogues.
- add callbacks for installer updates while doing URL xfers.

View File

@ -94,6 +94,7 @@ void htFree(hashTable ht) {
if (ht->keySize && b) free(b->key);
while (b) {
n = b->next;
if (b->data) free(b->data); /* XXX ==> LEAK */
free(b);
b = n;
}

View File

@ -61,6 +61,45 @@ static int ensureOlder(rpmdb db, Header new, int dbOffset, rpmProblemSet probs,
const void * key);
static void skipFiles(struct fileInfo * fi, int noDocs);
static void freeFi(struct fileInfo *fi)
{
if (fi->h) {
headerFree(fi->h); fi->h = NULL;
}
if (fi->actions) {
free(fi->actions); fi->actions = NULL;
}
if (fi->replaced) {
free(fi->replaced); fi->replaced = NULL;
}
if (fi->fl) {
free(fi->fl); fi->fl = NULL;
}
if (fi->flinks) {
free(fi->flinks); fi->flinks = NULL;
}
if (fi->fmd5s) {
free(fi->fmd5s); fi->fmd5s = NULL;
}
}
static void freeFl(rpmTransactionSet ts, struct fileInfo *flList)
{
struct availableList * al = &ts->addedPackages;
struct availablePackage * alp;
struct fileInfo *fi;
int i;
for (alp = al->list, fi = flList; (alp - al->list) < al->size;
alp++, fi++) {
freeFi(fi);
}
for (i = 0; i < ts->numRemovedPackages; i++, fi++) {
freeFi(fi);
}
}
#define XSTRCMP(a, b) ((!(a) && !(b)) || ((a) && (b) && !strcmp((a), (b))))
#define NOTIFY(_x) if (notify) notify _x
@ -145,6 +184,7 @@ NOTIFY((NULL, RPMCALLBACK_TRANS_START, 2, ts->numRemovedPackages,
if (headerGetEntry(h, RPMTAG_FILENAMES, NULL, NULL,
&fileCount))
totalFileCount += fileCount;
headerFree(h); /* XXX ==> LEAK */
}
NOTIFY((h, RPMCALLBACK_TRANS_PROGRESS, i, ts->numRemovedPackages,
@ -231,6 +271,9 @@ NOTIFY((fi->h, RPMCALLBACK_TRANS_PROGRESS, i, ts->numRemovedPackages,
(void *) &fi->fflags, NULL);
headerGetEntryMinMemory(fi->h, RPMTAG_FILEMD5S, NULL,
(void *) &fi->fmd5s, NULL);
fi->flinks = NULL; /* XXX FIXME W2DO? */
headerGetEntryMinMemory(fi->h, RPMTAG_FILEMODES, NULL,
(void *) &fi->fmodes, NULL);
headerGetEntryMinMemory(fi->h, RPMTAG_FILESTATES, NULL,
@ -332,10 +375,10 @@ NOTIFY((NULL, RPMCALLBACK_TRANS_START, 7, al->size, NULL, notifyData));
for (alp = al->list, fi = flList; (alp - al->list) < al->size;
alp++, fi++) {
if (fi->fc) {
free(fi->fl);
free(fi->fl); fi->fl = NULL;
if (fi->type == ADDED) {
free(fi->fmd5s);
free(fi->flinks);
free(fi->fmd5s); fi->fmd5s = NULL;
free(fi->flinks); fi->flinks = NULL;
}
}
}
@ -349,19 +392,13 @@ NOTIFY((NULL, RPMCALLBACK_TRANS_START, 8, al->size, NULL, notifyData));
for (alp = al->list, fi = flList; (alp - al->list) < al->size;
alp++, fi++) {
if (fi->fc) {
if (fi->fc)
headerFree(hdrs[alp - al->list]);
free(fi->actions);
fi->actions = NULL;
}
/* XXX FIXME: This smells like a memory leak. */
if (fi->actions) {
free(fi->actions);
fi->actions = NULL;
}
freeFi(fi); /* XXX ==> LEAK */
}
NOTIFY((NULL, RPMCALLBACK_TRANS_STOP, 8, al->size, NULL, notifyData));
freeFl(ts, flList); /* XXX ==> LEAK */
return al->size + ts->numRemovedPackages;
}
@ -405,21 +442,12 @@ NOTIFY((NULL, RPMCALLBACK_TRANS_START, 9, al->size, NULL, notifyData));
headerFree(hdrs[alp - al->list]);
/* XXX FIXME: This smells like a memory leak. */
if (fi->actions) {
free(fi->actions);
fi->actions = NULL;
}
/* XXX FIXME: This smells like a memory leak. */
if (fi->replaced) {
free(fi->replaced);
fi->replaced = NULL;
}
if (!alp->fd && fd)
notify(fi->h, RPMCALLBACK_INST_CLOSE_FILE, 0, 0, alp->key,
notifyData);
freeFi(fi); /* XXX ==> LEAK */
}
NOTIFY((NULL, RPMCALLBACK_TRANS_STOP, 9, al->size, NULL, notifyData));
@ -437,20 +465,14 @@ NOTIFY((fi->h, RPMCALLBACK_UNINST_PROGRESS, i, ts->numRemovedPackages,
ourrc++;
/* XXX FIXME: This smells like a memory leak. */
if (fi->actions) {
free(fi->actions);
fi->actions = NULL;
}
/* XXX FIXME: This smells like a memory leak. */
if (fi->replaced) {
free(fi->replaced);
fi->replaced = NULL;
}
freeFi(fi); /* XXX ==> LEAK */
}
NOTIFY((NULL, RPMCALLBACK_UNINST_STOP, 0, ts->numRemovedPackages,
NULL, notifyData));
freeFl(ts, flList); /* XXX ==> LEAK */
if (ourrc)
return -1;
else

View File

@ -7,7 +7,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 1999-02-24 23:55-0500\n"
"POT-Creation-Date: 1999-02-28 13:34-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -1427,26 +1427,26 @@ msgstr ""
msgid "Password for %s@%s: "
msgstr ""
#: ../url.c:145 ../url.c:167
#: ../url.c:146 ../url.c:168
#, c-format
msgid "error: %sport must be a number\n"
msgstr ""
#: ../url.c:249
#: ../url.c:250
msgid "url port must be a number\n"
msgstr ""
#: ../url.c:285
#: ../url.c:286
#, c-format
msgid "logging into %s as %s, pw %s\n"
msgstr ""
#: ../lib/rpmdb.c:168 ../url.c:396
#: ../lib/rpmdb.c:168 ../url.c:397
#, c-format
msgid "failed to open %s\n"
msgstr ""
#: ../url.c:411
#: ../url.c:412
#, c-format
msgid "failed to create %s\n"
msgstr ""
@ -2961,57 +2961,57 @@ msgstr ""
msgid "Too many args in default line at %s:%d"
msgstr ""
#: ../lib/rpmrc.c:624
#: ../lib/rpmrc.c:627
#, c-format
msgid "Cannot expand %s"
msgstr ""
#: ../lib/rpmrc.c:639
#: ../lib/rpmrc.c:642
#, c-format
msgid "Unable to open %s for reading: %s."
msgstr ""
#: ../lib/rpmrc.c:673
#: ../lib/rpmrc.c:676
#, c-format
msgid "Failed to read %s: %s."
msgstr ""
#: ../lib/rpmrc.c:704
#: ../lib/rpmrc.c:707
#, c-format
msgid "missing ':' at %s:%d"
msgstr ""
#: ../lib/rpmrc.c:720 ../lib/rpmrc.c:768
#: ../lib/rpmrc.c:723 ../lib/rpmrc.c:771
#, c-format
msgid "missing argument for %s at %s:%d"
msgstr ""
#: ../lib/rpmrc.c:734
#: ../lib/rpmrc.c:737
#, c-format
msgid "expansion failed at %s:d \"%s\""
msgstr ""
#: ../lib/rpmrc.c:740
#: ../lib/rpmrc.c:743
#, c-format
msgid "cannot open %s at %s:%d"
msgstr ""
#: ../lib/rpmrc.c:758
#: ../lib/rpmrc.c:761
#, c-format
msgid "missing architecture for %s at %s:%d"
msgstr ""
#: ../lib/rpmrc.c:825
#: ../lib/rpmrc.c:828
#, c-format
msgid "bad option '%s' at %s:%d"
msgstr ""
#: ../lib/rpmrc.c:1183
#: ../lib/rpmrc.c:1186
#, c-format
msgid "Unknown system: %s\n"
msgstr ""
#: ../lib/rpmrc.c:1184
#: ../lib/rpmrc.c:1187
msgid "Please contact rpm-list@redhat.com\n"
msgstr ""
@ -3137,17 +3137,17 @@ msgstr ""
msgid "Invalid signature spec in rc file"
msgstr ""
#: ../lib/transaction.c:662
#: ../lib/transaction.c:695
#, c-format
msgid "relocating %s to %s\n"
msgstr ""
#: ../lib/transaction.c:668
#: ../lib/transaction.c:701
#, c-format
msgid "excluding %s\n"
msgstr ""
#: ../lib/transaction.c:756
#: ../lib/transaction.c:789
#, c-format
msgid "%s skipped due to missingok flag\n"
msgstr ""

View File

@ -1,8 +1,8 @@
Summary: Red Hat Package Manager
Name: rpm
%define version 2.91
%define version 2.92
Version: %{version}
Release: 18
Release: 1
Group: Utilities/System
Source: ftp://ftp.rpm.org/pub/rpm/dist/rpm-2.5.x/rpm-%{version}.tar.gz
Copyright: GPL