From 8ab0c4d40130f916feb5a1566e757be6de7deff0 Mon Sep 17 00:00:00 2001
From: Luke Howard <lukeh@openldap.org>
Date: Tue, 21 Jan 2003 05:56:46 +0000
Subject: [PATCH] fix SLAPI_MODIFY_MODS pointer error

---
 servers/slapd/modify.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c
index f388f2e374..f6dbac13fe 100644
--- a/servers/slapd/modify.c
+++ b/servers/slapd/modify.c
@@ -809,6 +809,7 @@ static LDAPMod **Modifications2LDAPMods(Modifications **pmodlist)
 				sizeof(struct berval *) );
 			for( j = 0; ml->sml_bvalues[j].bv_val != NULL; j++ ) {
 				/* Take ownership of original values. */
+				modp->mod_bvalues[j] = (struct berval *)ch_malloc( sizeof(struct berval) );
 				modp->mod_bvalues[j]->bv_len = ml->sml_bvalues[j].bv_len;
 				modp->mod_bvalues[j]->bv_val = ml->sml_bvalues[j].bv_val;
 				ml->sml_bvalues[j].bv_len = 0;
@@ -896,7 +897,7 @@ static Modifications *LDAPMods2Modifications (LDAPMod **mods)
  */
 static void FreeLDAPMods (LDAPMod **mods)
 {
-	int i;
+	int i, j;
 
 	if (mods == NULL)
 		return;
@@ -907,6 +908,9 @@ static void FreeLDAPMods (LDAPMod **mods)
 		 * Modification list. Do free the containing array.
 		 */
 		if ( mods[i]->mod_op & LDAP_MOD_BVALUES ) {
+			for ( j = 0; mods[i]->mod_bvalues[j] != NULL; j++ ) {
+				ch_free( mods[i]->mod_bvalues[j] );
+			}
 			ch_free( mods[i]->mod_bvalues );
 		} else {
 			ch_free( mods[i]->mod_values );
-- 
GitLab