summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--debian/changelog3
-rw-r--r--lib/dbmodify.c22
3 files changed, 21 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 06dcb94fa..f2321fd81 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Sep 3 18:40:08 CDT 2002 Adam Heath <doogie@debian.org>
+
+ * lib/dbmodify.c: Fix double free in modstatdb_init, in the case that
+ modstatdb_shutdown was called previously.
+
Tue Sep 3 18:37:45 CDT 2002 Adam Heath <doogie@debian.org>
* lib/nfmalloc.c: Protect duplicate calls to obstack_free(),
diff --git a/debian/changelog b/debian/changelog
index 15fe395d9..7e9c20686 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,8 @@
dpkg (1.10.7) unstable; urgency=low
+ * Fix double free in modstatdb_init, in the case that modstatdb_shutdown
+ was called previously. Closes: #159515.
+
-- Adam Heath <doogie@debian.org> UNRELEASED
dpkg (1.10.6) unstable; urgency=low
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);
}