]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldap/search.c
fix previous commit
[openldap] / servers / slapd / back-ldap / search.c
index 510a4bba98ccbe0ca3d9a5d7f4fac3dd9204e32a..1a30eb6960e81ca78596bff6596a93c6c5385bff 100644 (file)
@@ -286,7 +286,6 @@ retry:
                } else if ( rc == LDAP_RES_SEARCH_ENTRY ) {
                        Entry           ent = { 0 };
                        struct berval   bdn = BER_BVNULL;
-                       int             abort = 0;
 
                        do_retry = 0;
 
@@ -297,7 +296,7 @@ retry:
                                rs->sr_attrs = op->ors_attrs;
                                rs->sr_operational_attrs = NULL;
                                rs->sr_flags = 0;
-                               abort = send_search_entry( op, rs );
+                               rc = rs->sr_err = send_search_entry( op, rs );
                                if ( !BER_BVISNULL( &ent.e_name ) ) {
                                        assert( ent.e_name.bv_val != bdn.bv_val );
                                        free( ent.e_name.bv_val );
@@ -310,8 +309,12 @@ retry:
                                entry_clean( &ent );
                        }
                        ldap_msgfree( res );
-                       if ( abort ) {
-                               ldap_abandon_ext( lc->lc_ld, msgid, NULL, NULL );
+                       if ( rc != LDAP_SUCCESS ) {
+                               if ( rc == LDAP_UNAVAILABLE ) {
+                                       rc = rs->sr_err = LDAP_OTHER;
+                               } else {
+                                       ldap_abandon_ext( lc->lc_ld, msgid, NULL, NULL );
+                               }
                                goto finish;
                        }
 
@@ -402,13 +405,22 @@ retry:
                        }
 
                        if ( match.bv_val != NULL ) {
+#ifndef LDAP_NULL_IS_NULL
                                if ( match.bv_val[ 0 ] == '\0' ) {
                                        LDAP_FREE( match.bv_val );
                                        BER_BVZERO( &match );
-                               } else {
+                               } else
+#endif /* LDAP_NULL_IS_NULL */
+                               {
                                        match.bv_len = strlen( match.bv_val );
                                }
                        }
+#ifndef LDAP_NULL_IS_NULL
+                       if ( rs->sr_text != NULL && rs->sr_text[ 0 ] == '\0' ) {
+                               LDAP_FREE( (char *)rs->sr_text );
+                               rs->sr_text = NULL;
+                       }
+#endif /* LDAP_NULL_IS_NULL */
 
                        /* cleanup */
                        if ( references ) {