From 3a2ddf155134e02f5aa421f739cb1ca3f034421c Mon Sep 17 00:00:00 2001 From: jbj Date: Thu, 19 Jul 2001 21:14:05 +0000 Subject: [PATCH] - fix: 4 memory leaks eliminated. CVS patchset: 4960 CVS date: 2001/07/19 21:14:05 --- CHANGES | 1 + lib/fsm.c | 2 ++ lib/psm.c | 2 ++ lib/query.c | 4 ++-- lib/rpmlib.h | 6 ++++++ lib/transaction.c | 2 +- rpmdb/rpmdb.c | 4 ++-- rpmio/rpmlog.c | 5 ++--- rpmqv.c | 2 ++ 9 files changed, 20 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index ace3ed9..71d1247 100644 --- a/CHANGES +++ b/CHANGES @@ -179,6 +179,7 @@ - python: add poptmodule.so bindings. - fix: %dev(...) needs to map rdev and mtime from metadata. - resurrect --specedit for i18n. + - fix: 4 memory leaks eliminated. 4.0 -> 4.0.[12] - add doxygen and lclint annotations most everywhere. diff --git a/lib/fsm.c b/lib/fsm.c index 6f09270..15c4ab0 100644 --- a/lib/fsm.c +++ b/lib/fsm.c @@ -929,6 +929,7 @@ static int fsmMakeLinks(/*@special@*/ FSM_t fsm) if (i == fsm->li->createdPath) continue; fsm->ix = fsm->li->filex[i]; + fsm->path = _free(fsm->path); rc = fsmStage(fsm, FSM_MAP); rc = fsmStage(fsm, FSM_VERIFY); if (!rc) continue; @@ -943,6 +944,7 @@ static int fsmMakeLinks(/*@special@*/ FSM_t fsm) fsm->li->linksLeft--; } + fsm->path = _free(fsm->path); fsm->opath = _free(fsm->opath); fsm->ix = iterIndex; diff --git a/lib/psm.c b/lib/psm.c index 9fe34f9..822e8f4 100644 --- a/lib/psm.c +++ b/lib/psm.c @@ -916,7 +916,9 @@ static int runScript(PSM_t psm, Header h, } } else { out = fdDup(STDOUT_FILENO); +#ifdef DYING out = fdLink(out, "runScript persist"); +#endif } if (out == NULL) return 1; /* XXX can't happen */ diff --git a/lib/query.c b/lib/query.c index 2408edf..182c766 100644 --- a/lib/query.c +++ b/lib/query.c @@ -418,9 +418,9 @@ printNewSpecfile(Spec spec) for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) { const char *pkgname; h = pkg->header; - headerNVR(h, &pkgname, NULL, NULL); + (void) headerNVR(h, &pkgname, NULL, NULL); if (!strcmp(pkgname, fmt)) - break; + /*@innerbreak@*/ break; } if (pkg == NULL || h == NULL) h = spec->packages->header; diff --git a/lib/rpmlib.h b/lib/rpmlib.h index dff6bfa..a34c729 100644 --- a/lib/rpmlib.h +++ b/lib/rpmlib.h @@ -641,6 +641,12 @@ typedef /*@abstract@*/ struct rpmdb_s * rpmdb; typedef /*@abstract@*/ struct _dbiIndexSet * dbiIndexSet; /** \ingroup rpmdb + * Tags for which rpmdb indices will be built. + */ +/*@only@*/ /*@null@*/ extern int * dbiTags; +extern int dbiTagsMax; + +/** \ingroup rpmdb * Open rpm database. * @param root path to top of install tree * @retval dbp address of rpm database diff --git a/lib/transaction.c b/lib/transaction.c index c17587c..5cd7e10 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -1719,9 +1719,9 @@ int rpmRunTransactions( rpmTransactionSet ts, continue; } +#ifdef DYING /* Allocate file actions (and initialize to FA_UNKNOWN) */ fi->actions = xcalloc(fi->fc, sizeof(*fi->actions)); -#ifdef DYING hdrs[i] = relocateFileList(ts, fi, fi->ap, fi->h, fi->actions); #else { Header foo = relocateFileList(ts, fi, fi->ap, fi->h, fi->actions); diff --git a/rpmdb/rpmdb.c b/rpmdb/rpmdb.c index 42a7db3..bc69d45 100644 --- a/rpmdb/rpmdb.c +++ b/rpmdb/rpmdb.c @@ -36,8 +36,8 @@ static int _db_filter_dups = 0; #define _DBI_PERMS 0644 #define _DBI_MAJOR -1 -static int dbiTagsMax = 0; -/*@only@*/ /*@null@*/ static int *dbiTags = NULL; +/*@globstate@*/ /*@null@*/ int * dbiTags = NULL; +int dbiTagsMax = 0; /** * Return dbi index used for rpm tag. diff --git a/rpmio/rpmlog.c b/rpmio/rpmlog.c index 5c6a49e..755a238 100644 --- a/rpmio/rpmlog.c +++ b/rpmio/rpmlog.c @@ -162,13 +162,12 @@ static void vrpmlog (unsigned code, const char *fmt, va_list ap) else recs = xrealloc(recs, (nrecs+2) * sizeof(*recs)); recs[nrecs].code = code; - recs[nrecs].message = msg = msgbuf; - msgbuf = NULL; + recs[nrecs].message = msg = xrealloc(msgbuf, strlen(msgbuf)+1); + msgbuf = NULL; /* XXX don't free at exit. */ recs[nrecs+1].code = 0; recs[nrecs+1].message = NULL; ++nrecs; - if (_rpmlogCallback) { _rpmlogCallback(); return; /* XXX Preserve legacy rpmError behavior. */ diff --git a/rpmqv.c b/rpmqv.c index c689199..439be7e 100755 --- a/rpmqv.c +++ b/rpmqv.c @@ -1152,6 +1152,8 @@ exit: freeNames(); freeFilesystems(); urlFreeCache(); + rpmlogClose(); + dbiTags = _free(dbiTags); #ifdef IAM_RPMQV qva->qva_queryFormat = _free(qva->qva_queryFormat); -- 2.7.4