From 992c3f3a7b6bbbc6d3af8b00f9d18f1d857b7f81 Mon Sep 17 00:00:00 2001
From: Howard Chu <hyc@openldap.org>
Date: Mon, 3 Sep 2007 00:15:33 +0000
Subject: [PATCH] Schema undo fix from HEAD

---
 servers/slapd/bconfig.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/servers/slapd/bconfig.c b/servers/slapd/bconfig.c
index fd57476fda..79b99d1fec 100644
--- a/servers/slapd/bconfig.c
+++ b/servers/slapd/bconfig.c
@@ -1149,10 +1149,14 @@ config_generic(ConfigArgs *c) {
 			break;
 
 		case CFG_OC: {
-			CfEntryInfo *ce = c->ca_entry->e_private;
-			/* can't modify the hardcoded schema */
-			if ( ce->ce_parent->ce_type == Cft_Global )
-				return 1;
+			CfEntryInfo *ce;
+			/* Can be NULL when undoing a failed add */
+			if ( c->ca_entry ) {
+				ce = c->ca_entry->e_private;
+				/* can't modify the hardcoded schema */
+				if ( ce->ce_parent->ce_type == Cft_Global )
+					return 1;
+				}
 			}
 			cfn = c->private;
 			if ( c->valx < 0 ) {
@@ -1183,10 +1187,14 @@ config_generic(ConfigArgs *c) {
 			break;
 
 		case CFG_ATTR: {
-			CfEntryInfo *ce = c->ca_entry->e_private;
-			/* can't modify the hardcoded schema */
-			if ( ce->ce_parent->ce_type == Cft_Global )
-				return 1;
+			CfEntryInfo *ce;
+			/* Can be NULL when undoing a failed add */
+			if ( c->ca_entry ) {
+				ce = c->ca_entry->e_private;
+				/* can't modify the hardcoded schema */
+				if ( ce->ce_parent->ce_type == Cft_Global )
+					return 1;
+				}
 			}
 			cfn = c->private;
 			if ( c->valx < 0 ) {
-- 
GitLab