[evolution-data-server/gnome-2-32] e_dbhash_new: Close and reopen db handle to avoid memory leak
- From: Patrick Ohly <pohly src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/gnome-2-32] e_dbhash_new: Close and reopen db handle to avoid memory leak
- Date: Tue, 7 Jun 2011 08:49:10 +0000 (UTC)
commit c1152557704e691a527ab1f7243e9e2c798058fe
Author: Christophe Dumez <christophe dumez intel com>
Date: Mon May 30 14:43:14 2011 +0300
e_dbhash_new: Close and reopen db handle to avoid memory leak
According to the documentation, "If DB->open fails,
the DB->close method should be called to discard the DB
handle". The current code was calling open() again on
the same handle without closing it it first, possibly
causing memory leaks.
This patch is adapted from commit
37d3c0f65c989afe9ffc2d734d86b2ae0019edae in eds-fremantle GIT
repository.
libebackend/e-dbhash.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/libebackend/e-dbhash.c b/libebackend/e-dbhash.c
index f720f84..af73b7b 100644
--- a/libebackend/e-dbhash.c
+++ b/libebackend/e-dbhash.c
@@ -34,6 +34,13 @@ e_dbhash_new (const gchar *filename)
rv = (*db->open) (db, NULL, filename, NULL, DB_HASH, 0, 0666);
if (rv != 0) {
+ /* Close and re-create the db handle to avoid memory leak */
+ db->close (db, 0);
+ rv = db_create (&db, NULL, 0);
+ if (rv != 0) {
+ return NULL;
+ }
+
rv = (*db->open) (db, NULL, filename, NULL, DB_HASH, DB_CREATE, 0666);
if (rv != 0) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]