]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/syncprov.c
check for NULL backend (ITS#6490)
[openldap] / servers / slapd / overlays / syncprov.c
index a974a83b823cbfe53cc37e287e864128ea9e86ae..6cb7cfb17df44c83678150a0aad9a98b5c01dcc5 100644 (file)
@@ -783,7 +783,8 @@ syncprov_free_syncop( syncops *so )
        GroupAssertion *ga, *gnext;
 
        ldap_pvt_thread_mutex_lock( &so->s_mutex );
-       if ( --so->s_inuse > 0 ) {
+       /* already being freed, or still in use */
+       if ( !so->s_inuse || --so->s_inuse > 0 ) {
                ldap_pvt_thread_mutex_unlock( &so->s_mutex );
                return;
        }
@@ -931,9 +932,9 @@ syncprov_qplay( Operation *op, syncops *so )
                ldap_pvt_thread_mutex_unlock( &so->s_mutex );
 
                if ( sr->s_mode == LDAP_SYNC_NEW_COOKIE ) {
-                   SlapReply rs = { REP_INTERMEDIATE };
+                       SlapReply rs = { REP_INTERMEDIATE };
 
-                   rc = syncprov_sendinfo( op, &rs, LDAP_TAG_SYNC_NEW_COOKIE,
+                       rc = syncprov_sendinfo( op, &rs, LDAP_TAG_SYNC_NEW_COOKIE,
                                &sr->s_csn, 0, NULL, 0 );
                } else {
                        opc.sdn = sr->s_dn;
@@ -945,11 +946,11 @@ syncprov_qplay( Operation *op, syncops *so )
 
                        rc = syncprov_sendresp( op, &opc, so, sr->s_mode );
 
-                       if ( opc.se ) {
-                               if ( !dec_mutexint( opc.se->e_private )) {
-                                       opc.se->e_private = NULL;
-                                       entry_free ( opc.se );
-                               }
+               }
+               if ( sr->s_e ) {
+                       if ( !dec_mutexint( sr->s_e->e_private )) {
+                               sr->s_e->e_private = NULL;
+                               entry_free ( sr->s_e );
                        }
                }
 
@@ -2561,8 +2562,7 @@ no_change:                if ( !(op->o_sync_mode & SLAP_SYNC_PERSIST) ) {
                                        ber_bvarray_free_x( ctxcsn, op->o_tmpmemctx );
                                if ( sids )
                                        op->o_tmpfree( sids, op->o_tmpmemctx );
-                               send_ldap_result( op, rs );
-                               return rs->sr_err;
+                               goto bailout;
                        }
                }
        } else {