]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#10336 slapd-mdb: fix delete on empty DB
authorHoward Chu <hyc@openldap.org>
Tue, 13 May 2025 16:22:28 +0000 (17:22 +0100)
committerHoward Chu <hyc@openldap.org>
Tue, 13 May 2025 17:02:27 +0000 (18:02 +0100)
Don't assume parent of target entry will always exist.

servers/slapd/back-mdb/delete.c

index 186127b17916335d6f50088fb4637dc1b42a3631..f1d2be9e513acefcbc6f1b23c1c3fa067127a7fa 100644 (file)
@@ -148,17 +148,18 @@ mdb_delete( Operation *op, SlapReply *rs )
                        "<=- " LDAP_XSTRING(mdb_delete) ": no such object %s\n",
                        op->o_req_dn.bv_val );
 
-               rs->sr_matched = ch_strdup( e->e_dn );
-               if ( is_entry_referral( e )) {
-                       BerVarray ref = get_entry_referrals( op, e );
-                       rs->sr_ref = referral_rewrite( ref, &e->e_name,
-                               &op->o_req_dn, LDAP_SCOPE_DEFAULT );
-                       ber_bvarray_free( ref );
-               } else {
-                       rs->sr_ref = NULL;
+               rs->sr_ref = NULL;
+               if ( e ) {
+                       rs->sr_matched = ch_strdup( e->e_dn );
+                       if ( is_entry_referral( e )) {
+                               BerVarray ref = get_entry_referrals( op, e );
+                               rs->sr_ref = referral_rewrite( ref, &e->e_name,
+                                       &op->o_req_dn, LDAP_SCOPE_DEFAULT );
+                               ber_bvarray_free( ref );
+                       }
+                       mdb_entry_return( op, e );
+                       e = NULL;
                }
-               mdb_entry_return( op, e );
-               e = NULL;
 
                rs->sr_err = LDAP_REFERRAL;
                rs->sr_flags = REP_MATCHED_MUSTBEFREED | REP_REF_MUSTBEFREED;