Commit 0c8afb03 authored by Ondřej Kuzník's avatar Ondřej Kuzník Committed by Quanah Gibson-Mount
Browse files

ITS#9444 Manage sr_ref/sr_matched flags accordingly

send_ldap_response() clears them immediately even if we never attached
the data to be freed, so when we reinstate them, the flags are gone and
the next send_ldap_response() doesn't consider freeing them.
parent f7888739
...@@ -383,8 +383,8 @@ retry:; ...@@ -383,8 +383,8 @@ retry:;
default: default:
/* remember the text before it's freed in ldap_back_op_result */ /* remember the text before it's freed in ldap_back_op_result */
if ( lb.lb_text ) { if ( lb->lb_text ) {
ber_memfree_x( lb.lb_text, op->o_tmpmemctx ); ber_memfree_x( lb->lb_text, op->o_tmpmemctx );
} }
lb->lb_text = ber_strdup_x( rs->sr_text, op->o_tmpmemctx ); lb->lb_text = ber_strdup_x( rs->sr_text, op->o_tmpmemctx );
return rs->sr_err; return rs->sr_err;
...@@ -971,6 +971,7 @@ ldap_chain_response( Operation *op, SlapReply *rs ) ...@@ -971,6 +971,7 @@ ldap_chain_response( Operation *op, SlapReply *rs )
const char *text = NULL; const char *text = NULL;
const char *matched; const char *matched;
BerVarray ref; BerVarray ref;
slap_mask_t flags = 0;
struct berval ndn = op->o_ndn; struct berval ndn = op->o_ndn;
int sr_err = rs->sr_err; int sr_err = rs->sr_err;
...@@ -1034,6 +1035,9 @@ ldap_chain_response( Operation *op, SlapReply *rs ) ...@@ -1034,6 +1035,9 @@ ldap_chain_response( Operation *op, SlapReply *rs )
ref = rs->sr_ref; ref = rs->sr_ref;
rs->sr_ref = NULL; rs->sr_ref = NULL;
flags = rs->sr_flags & (REP_MATCHED_MUSTBEFREED | REP_REF_MUSTBEFREED);
rs->sr_flags &= ~flags;
/* we need this to know if back-ldap returned any result */ /* we need this to know if back-ldap returned any result */
lb.lb_lc = lc; lb.lb_lc = lc;
sc2.sc_next = sc->sc_next; sc2.sc_next = sc->sc_next;
...@@ -1169,6 +1173,7 @@ cannot_chain:; ...@@ -1169,6 +1173,7 @@ cannot_chain:;
rs->sr_text = text; rs->sr_text = text;
rs->sr_matched = matched; rs->sr_matched = matched;
rs->sr_ref = ref; rs->sr_ref = ref;
rs->sr_flags |= flags;
} }
#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
break; break;
...@@ -1189,6 +1194,8 @@ dont_chain:; ...@@ -1189,6 +1194,8 @@ dont_chain:;
rs->sr_text = text; rs->sr_text = text;
rs->sr_matched = matched; rs->sr_matched = matched;
rs->sr_ref = ref; rs->sr_ref = ref;
rs->sr_flags |= flags;
op->o_bd = bd; op->o_bd = bd;
op->o_callback = sc; op->o_callback = sc;
op->o_ndn = ndn; op->o_ndn = ndn;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment