]> git.sur5r.net Git - openldap/commitdiff
ITS#2805 fix core dump using LDBM
authorHoward Chu <hyc@openldap.org>
Mon, 3 Nov 2003 09:54:28 +0000 (09:54 +0000)
committerHoward Chu <hyc@openldap.org>
Mon, 3 Nov 2003 09:54:28 +0000 (09:54 +0000)
servers/slapd/syncrepl.c

index b7d4528d64e71b55a7e2f4ab2d3204e311202417..b17754d420638a7169c11f2698b820c3edc1c35f 100644 (file)
@@ -423,13 +423,16 @@ do_syncrep2(
                        switch( ldap_msgtype( msg ) ) {
                        case LDAP_RES_SEARCH_ENTRY:
                                ldap_get_entry_controls( si->si_ld, msg, &rctrls );
-                               if ( rctrls ) {
-                                       rctrlp = *rctrls;
-                                       ber_init2( ber, &rctrlp->ldctl_value, LBER_USE_DER );
-                                       ber_scanf( ber, "{em", &syncstate, &syncUUID );
-                                       if ( ber_peek_tag( ber, &len ) == LDAP_SYNC_TAG_COOKIE ) {
-                                               ber_scanf( ber, "m}", &syncCookie );
-                                       }
+                               /* we can't work without the control */
+                               if ( !rctrls ) {
+                                       rc = -1;
+                                       goto done;
+                               }
+                               rctrlp = *rctrls;
+                               ber_init2( ber, &rctrlp->ldctl_value, LBER_USE_DER );
+                               ber_scanf( ber, "{em", &syncstate, &syncUUID );
+                               if ( ber_peek_tag( ber, &len ) == LDAP_SYNC_TAG_COOKIE ) {
+                                       ber_scanf( ber, "m}", &syncCookie );
                                }
                                entry = syncrepl_message_to_entry( si, op, msg,
                                        &modlist, syncstate );
@@ -438,9 +441,7 @@ do_syncrep2(
                                if ( syncCookie.bv_len ) {
                                        syncrepl_updateCookie( si, op, psub, &syncCookie );
                                }
-                               if ( rctrls ) {
-                                       ldap_controls_free( rctrls );
-                               }
+                               ldap_controls_free( rctrls );
                                if ( modlist ) {
                                        slap_mods_free( modlist );
                                }