bogofilter/0001-Fix-memory-leak-when-creating-a-new-bdb-file-125.patch
2019-02-13 09:13:03 +01:00

51 lines
1.7 KiB
Diff

From 861b6c058b36fafefcdca21be180fa44046db4a0 Mon Sep 17 00:00:00 2001
From: Georg Sauthoff <mail@georg.so>
Date: Mon, 11 Feb 2019 10:01:14 +0100
Subject: [PATCH 01/11] Fix memory leak when creating a new bdb file (#125)
cf. https://sourceforge.net/p/bogofilter/bugs/125/
---
src/datastore_db.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/datastore_db.c b/src/datastore_db.c
index 4b58462..d0bcfa1 100644
--- a/src/datastore_db.c
+++ b/src/datastore_db.c
@@ -630,13 +630,30 @@ retry_db_open:
if (ret != 0) {
err = (ret != ENOENT) || (opt_flags == DB_RDONLY);
if (!err) {
- if (
+ ret =
#if DB_EQUAL(4,1)
- (ret = DB_SET_FLAGS(dbp, DB_CHKSUM_SHA1)) != 0 ||
+ (DB_SET_FLAGS(dbp, DB_CHKSUM_SHA1)) != 0 ||
#endif
#if DB_AT_LEAST(4,2)
(ret = DB_SET_FLAGS(dbp, DB_CHKSUM)) != 0 ||
#endif
+ 0;
+ if (!ret) {
+ dbp->close(dbp, 0);
+ if ((ret = db_create (&dbp, dbe, 0)) != 0) {
+ print_error(__FILE__, __LINE__, "(db) db_create, err: %d, %s",
+ ret, db_strerror(ret));
+ goto open_err;
+ }
+ handle->dbp = dbp;
+#ifdef ENABLE_MEMDEBUG
+ if (eTransaction == T_DISABLED)
+ dbp->set_alloc(dbp, md_malloc, md_realloc, md_free);
+ else
+ dbe->set_alloc(dbe, md_malloc, md_realloc, md_free);
+#endif
+ }
+ if (ret ||
(ret = DB_OPEN(dbp, bfp, NULL, dbtype, opt_flags | DB_CREATE | DB_EXCL | retryflag, DS_MODE)))
err = true;
if (!err)
--
2.20.1