From 14a3efa48a79e0ed2d8136f60bf232e132ed2f35 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Tue, 13 Jan 2015 22:43:18 +0000 Subject: [PATCH] plug unlikely memleak (coverity) --- servers/slapd/back-bdb/dbcache.c | 2 ++ servers/slapd/back-bdb/init.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/servers/slapd/back-bdb/dbcache.c b/servers/slapd/back-bdb/dbcache.c index d3044ef6dc..da057676cb 100644 --- a/servers/slapd/back-bdb/dbcache.c +++ b/servers/slapd/back-bdb/dbcache.c @@ -195,6 +195,8 @@ bdb_db_cache( "bdb_db_cache: db_open(%s) failed: %s (%d)\n", name->bv_val, db_strerror(rc), rc ); ldap_pvt_thread_mutex_unlock( &bdb->bi_database_mutex ); + db->bdi_db->close( db->bdi_db, 0 ); + ch_free( db ); return rc; } diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index f08b113e78..d1b4b16215 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -406,6 +406,7 @@ shm_retry: Debug( LDAP_DEBUG_ANY, LDAP_XSTRING(bdb_db_open) ": %s\n", cr->msg, 0, 0 ); + ch_free( db ); goto fail; } @@ -419,6 +420,8 @@ shm_retry: Debug( LDAP_DEBUG_ANY, LDAP_XSTRING(bdb_db_open) ": %s\n", cr->msg, 0, 0 ); + db->bdi_db->close( db->bdi_db, 0 ); + ch_free( db ); goto fail; } } @@ -433,6 +436,8 @@ shm_retry: Debug( LDAP_DEBUG_ANY, LDAP_XSTRING(bdb_db_open) ": %s\n", cr->msg, 0, 0 ); + db->bdi_db->close( db->bdi_db, 0 ); + ch_free( db ); goto fail; } } @@ -504,6 +509,7 @@ shm_retry: LDAP_XSTRING(bdb_db_open) ": %s\n", cr->msg, 0, 0 ); db->bdi_db->close( db->bdi_db, 0 ); + ch_free( db ); goto fail; } -- 2.39.5