From 7f6dd31c6a530e3436960c435392b97c86661438 Mon Sep 17 00:00:00 2001
From: Rich Megginson <rmeggins@redhat.com>
Date: Mon, 21 May 2012 09:08:04 -0600
Subject: [PATCH] Ticket #321 - krbExtraData is being null modified and replicated on each ssh login

Bug Description: Crash during IPA install
Fix Description: Have to free the mod before moving the unremoved mods
down the list on top of the freed mod.
---
 .../plugins/replication/repl5_protocol_util.c      |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/ldap/servers/plugins/replication/repl5_protocol_util.c b/ldap/servers/plugins/replication/repl5_protocol_util.c
index 3327405..30d211a 100644
--- a/ldap/servers/plugins/replication/repl5_protocol_util.c
+++ b/ldap/servers/plugins/replication/repl5_protocol_util.c
@@ -707,6 +707,11 @@ repl5_strip_fractional_mods(Repl_Agmt *agmt, LDAPMod ** mods)
 				 */
 				if (0 == slapi_attr_type_cmp(mods[j]->mod_type, a[i], SLAPI_TYPE_CMP_SUBTYPE))
 				{
+					/* Adjust value of j, implicit in not incrementing it */
+					/* Free this mod */
+					ber_bvecfree(mods[j]->mod_bvalues);
+					slapi_ch_free((void **)&(mods[j]->mod_type));
+					slapi_ch_free((void **)&mods[j]);
 					/* Move down all subsequent mods */
 					for (k = j; mods[k+1] ; k++)
 					{
@@ -714,11 +719,6 @@ repl5_strip_fractional_mods(Repl_Agmt *agmt, LDAPMod ** mods)
 					}
 					/* Zero the end of the array */
 					mods[k] = NULL;
-					/* Adjust value of j, implicit in not incrementing it */
-					/* Free this mod */
-					ber_bvecfree(mods[j]->mod_bvalues);
-					slapi_ch_free((void **)&(mods[j]->mod_type));
-					slapi_ch_free((void **)&mods[j]);
 				} else {
 					j++;
 				}
-- 
1.7.1

