summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAdam Heath <doogie@debian.org>2002-09-03 23:36:47 +0000
committerAdam Heath <doogie@debian.org>2002-09-03 23:36:47 +0000
commitfe838585164d3a19ac5daa25f49f078264bc7a96 (patch)
tree81f8dba7597ae942930f7016b67c24df4d49ccc2 /lib
parenta5e8288468134ac71b0357a58ded20b883607081 (diff)
downloaddpkg-fe838585164d3a19ac5daa25f49f078264bc7a96.tar.gz
Fix double free in modstatdb_init, in the case that modstatdb_shutdown was
called previously.
Diffstat (limited to 'lib')
-rw-r--r--lib/dbmodify.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/dbmodify.c b/lib/dbmodify.c
index 2b69d3fde..d31317b62 100644
--- a/lib/dbmodify.c
+++ b/lib/dbmodify.c
@@ -119,13 +119,15 @@ static void createimptmp(void) {
onerr_abort--;
}
+const struct fni { const char *suffix; char **store; } fnis[]= {
+ { STATUSFILE, &statusfile },
+ { AVAILFILE, &availablefile },
+ { UPDATESDIR IMPORTANTTMP, &importanttmpfile },
+ { NULL, NULL }
+};
+
enum modstatdb_rw modstatdb_init(const char *adir, enum modstatdb_rw readwritereq) {
- static const struct fni { const char *suffix; char **store; } fnis[]= {
- { STATUSFILE, &statusfile },
- { AVAILFILE, &availablefile },
- { UPDATESDIR IMPORTANTTMP, &importanttmpfile },
- { NULL, NULL }
- }, *fnip;
+ const struct fni *fnip;
admindir= adir;
@@ -203,6 +205,7 @@ static void checkpoint(void) {
}
void modstatdb_shutdown(void) {
+ const struct fni *fnip;
switch (cstatus) {
case msdbrw_write:
checkpoint();
@@ -218,9 +221,10 @@ void modstatdb_shutdown(void) {
break;
}
- free(statusfile);
- free(availablefile);
- free(importanttmpfile);
+ for (fnip=fnis; fnip->suffix; fnip++) {
+ free(*fnip->store);
+ *fnip->store= NULL;
+ }
free(updatefnbuf);
}