From 399af8709e294df7031d80ecf953a73a79a22b31 Mon Sep 17 00:00:00 2001
From: Quanah Gibson-Mount <quanah@openldap.org>
Date: Wed, 26 Jan 2011 19:14:47 +0000
Subject: [PATCH] ITS#6797

---
 CHANGES                         | 1 +
 servers/slapd/overlays/pcache.c | 5 +++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/CHANGES b/CHANGES
index bde15fca03..cc7ca6933d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -88,6 +88,7 @@ OpenLDAP 2.4.24 Engineering
 	Fixed slapo-memberof with modrdn operations (ITS#6700)
 	Fixed slapo-pcache callback freeing (ITS#6640)
 	Fixed slapo-pcache to ignore undefined attrs (ITS#6600)
+	Fixed slapo-pcache pointer freeing (ITS#6797)
 	Fixed slapo-ppolicy don't update opattrs on consumers (ITS#6608)
 	Fixed slapo-ppolicy to allow userPassword deletion (ITS#6620)
 	Fixed slapo-refint when last group member is deleted (ITS#6663)
diff --git a/servers/slapd/overlays/pcache.c b/servers/slapd/overlays/pcache.c
index d3fb3ea7c8..91f0d052ce 100644
--- a/servers/slapd/overlays/pcache.c
+++ b/servers/slapd/overlays/pcache.c
@@ -599,7 +599,7 @@ url2query(
 	LDAPURLDesc	*lud = NULL;
 	struct berval	base,
 			tempstr = BER_BVNULL,
-			uuid;
+			uuid = BER_BVNULL;
 	int		attrset;
 	time_t		expiry_time;
 	time_t		refresh_time;
@@ -4726,6 +4726,7 @@ pcache_db_close(
 		connection_fake_init2( &conn, &opbuf, thrctx, 0 );
 		op = &opbuf.ob_op;
 
+                mod.sml_numvals = 0;
 		if ( qm->templates != NULL ) {
 			for ( tm = qm->templates; tm != NULL; tm = tm->qmnext ) {
 				for ( qc = tm->query; qc; qc = qc->next ) {
@@ -4733,6 +4734,7 @@ pcache_db_close(
 
 					if ( query2url( op, qc, &bv, 0 ) == 0 ) {
 						ber_bvarray_add_x( &vals, &bv, op->o_tmpmemctx );
+                				mod.sml_numvals++;
 					}
 				}
 			}
@@ -4759,7 +4761,6 @@ pcache_db_close(
 		mod.sml_type = ad_cachedQueryURL->ad_cname;
 		mod.sml_values = vals;
 		mod.sml_nvalues = NULL;
-                mod.sml_numvals = 1;
 		mod.sml_next = NULL;
 		Debug( pcache_debug,
 			"%sSETTING CACHED QUERY URLS\n",
-- 
GitLab