From 35e3f2ec89d6a5f25cad91cfa8529e2a623500ca Mon Sep 17 00:00:00 2001
From: Quanah Gibson-Mount <quanah@openldap.org>
Date: Wed, 29 Apr 2009 03:22:17 +0000
Subject: [PATCH] ITS#6054

---
 CHANGES                   |  3 ++-
 servers/slapd/sl_malloc.c | 17 ++++++++++++++---
 servers/slapd/syncrepl.c  |  4 ----
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/CHANGES b/CHANGES
index 80def09e06..e2adaf25b3 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,9 +1,10 @@
 OpenLDAP 2.4 Change Log
 
 OpenLDAP 2.4.17 Engineering
-	Fixed slapd normalization of updated schema attributes (ITS#5540)
 	Fixed slapd errno handling (ITS#6037)
+	Fixed slapd global alloc handling (ITS#6054)
 	Fixed slapd moduleload with static backends and modules (ITS#6016)
+	Fixed slapd normalization of updated schema attributes (ITS#5540)
 	Build Environment
 		Added test056-monitor (ITS#5540)
 		Added test057-memberof-refint (ITS#5395)
diff --git a/servers/slapd/sl_malloc.c b/servers/slapd/sl_malloc.c
index a5d8760b64..998d50bd8a 100644
--- a/servers/slapd/sl_malloc.c
+++ b/servers/slapd/sl_malloc.c
@@ -267,11 +267,19 @@ slap_sl_malloc(
 	int i, j;
 
 #ifdef SLAP_NO_SL_MALLOC
-	return ber_memalloc_x( size, NULL );
+	newptr = ber_memalloc_x( size, NULL );
+	if ( newptr ) return newptr;
+	assert( 0 );
+	exit( EXIT_FAILURE );
 #endif
 
 	/* ber_set_option calls us like this */
-	if (!ctx) return ber_memalloc_x(size, NULL);
+	if (!ctx) {
+		newptr = ber_memalloc_x( size, NULL );
+		if ( newptr ) return newptr;
+		assert( 0 );
+		exit( EXIT_FAILURE );
+	}
 
 	/* round up to doubleword boundary */
 	size += sizeof(ber_len_t) + pad;
@@ -375,7 +383,10 @@ slap_sl_realloc(void *ptr, ber_len_t size, void *ctx)
 		return slap_sl_malloc(size, ctx);
 
 #ifdef SLAP_NO_SL_MALLOC
-	return ber_memrealloc_x( ptr, size, NULL );
+	newptr = ber_memrealloc_x( ptr, size, NULL );
+	if ( newptr ) return newptr;
+	assert( 0 );
+	exit( EXIT_FAILURE );
 #endif
 
 	/* Not our memory? */
diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c
index 1c838d6a65..11ad325d76 100644
--- a/servers/slapd/syncrepl.c
+++ b/servers/slapd/syncrepl.c
@@ -1302,10 +1302,6 @@ do_syncrepl(
 	connection_fake_init( &conn, &opbuf, ctx );
 	op = &opbuf.ob_op;
 
-	/* use global malloc for now */
-	op->o_tmpmemctx = NULL;
-	op->o_tmpmfuncs = &ch_mfuncs;
-
 	op->o_managedsait = SLAP_CONTROL_NONCRITICAL;
 	be = si->si_be;
 
-- 
GitLab