- }
-
- if ( lr->lr_res_matched != NULL ) {
- LDAP_FREE( lr->lr_res_matched );
- lr->lr_res_matched = NULL;
- }
-
- if ( lr->lr_res_error != NULL ) {
- LDAP_FREE( lr->lr_res_error );
- lr->lr_res_error = NULL;
- }
-
- /* Since it's not a SearchReference, it must be a
- * result. Since we're not chasing the referral,
- * this request is done.
- */
- if ( v3ref == V3REF_TOAPP ) {
- lr->lr_status = LDAP_REQST_COMPLETED;
- Debug( LDAP_DEBUG_TRACE,
- "request done: ld %p msgid %d, "
- "referral returned to app\n",
- (void *)ld, lr->lr_msgid, 0);
- ldap_return_request( ld, lr, 1 );
- lr = NULL;
- }
- }
- }
- }
-
- /* All results that just return a status, i.e. don't return data
- * go through the following code. This code also chases V2 referrals
- * and checks if all referrals have been chased.
- */
- if ( tag != LDAP_RES_SEARCH_ENTRY &&
- v3ref != V3REF_TOAPP &&
- tag != LDAP_RES_INTERMEDIATE )
- {
- /* For a v3 search referral/reference, only come here if already chased it */
- if ( ld->ld_version >= LDAP_VERSION2 &&
- ( lr->lr_parent != NULL ||
- LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_REFERRALS) ) )
- {
- char *lr_res_error = NULL;
-
- tmpber = *ber; /* struct copy */
- if ( v3ref == V3REF_SUCCESS ) {
- /* V3 search reference or V3 referral
- * sucessfully chased. If this message
- * is a search result, then it has no more
- * outstanding referrals.
- */
- if ( tag == LDAP_RES_SEARCH_RESULT )
- refer_cnt = 0;