From d8c060104dadbd3045016bdc790c06a9e99abbab Mon Sep 17 00:00:00 2001
From: Howard Chu <hyc@openldap.org>
Date: Mon, 4 Aug 2014 13:35:02 -0700
Subject: [PATCH] ITS#7915 fix mdb_entry_release

In server mode, make sure the entry was actually ours
---
 servers/slapd/back-mdb/id2entry.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/servers/slapd/back-mdb/id2entry.c b/servers/slapd/back-mdb/id2entry.c
index 6fb8801393..cb4fb85aff 100644
--- a/servers/slapd/back-mdb/id2entry.c
+++ b/servers/slapd/back-mdb/id2entry.c
@@ -272,11 +272,11 @@ int mdb_entry_release(
 	/* slapMode : SLAP_SERVER_MODE, SLAP_TOOL_MODE,
 			SLAP_TRUNCATE_MODE, SLAP_UNDEFINED_MODE */
  
-	mdb_entry_return( op, e );
 	if ( slapMode & SLAP_SERVER_MODE ) {
 		OpExtra *oex;
 		LDAP_SLIST_FOREACH( oex, &op->o_extra, oe_next ) {
 			if ( oex->oe_key == mdb ) {
+				mdb_entry_return( op, e );
 				moi = (mdb_op_info *)oex;
 				/* If it was setup by entry_get we should probably free it */
 				if ( moi->moi_flag & MOI_FREEIT ) {
@@ -291,6 +291,8 @@ int mdb_entry_release(
 				break;
 			}
 		}
+	} else {
+		mdb_entry_return( op, e );
 	}
  
 	return 0;
-- 
GitLab