From 90e189c41f3b15a0bbc829fe3a5e45b8b3786c8f Mon Sep 17 00:00:00 2001
From: Ludwig Krispenz <lkrispen@redhat.com>
Date: Tue, 7 Feb 2017 17:02:00 +0100
Subject: [PATCH] fix for reg in 49008, check if ruv element exists

---
 ldap/servers/plugins/replication/repl5_ruv.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/ldap/servers/plugins/replication/repl5_ruv.c b/ldap/servers/plugins/replication/repl5_ruv.c
index 111b88f..d59e6d2 100644
--- a/ldap/servers/plugins/replication/repl5_ruv.c
+++ b/ldap/servers/plugins/replication/repl5_ruv.c
@@ -1705,8 +1705,14 @@ int ruv_cancel_csn_inprogress (RUV *ruv, const CSN *csn, ReplicaId local_rid)
 	replica = ruvGetReplica (ruv, prim_rid);
 	rc = csnplRemoveAll (replica->csnpl, prim_csn);
 	if (prim_rid != local_rid) {
-		replica = ruvGetReplica (ruv, local_rid);
-		rc = csnplRemoveAll (replica->csnpl, prim_csn);
+		if( local_rid != READ_ONLY_REPLICA_ID) {
+			replica = ruvGetReplica (ruv, local_rid);
+			if (replica) {
+				rc = csnplRemoveAll (replica->csnpl, prim_csn);
+			} else {
+				rc = RUV_NOTFOUND;
+			}
+		}
 	}
     } else {
 	rc = csnplRemove (replica->csnpl, csn);
-- 
2.5.5

