mirror of
https://github.com/samba-team/samba.git
synced 2025-08-29 13:49:30 +03:00
lib: poll_funcs : poll_funcs_context_slot_find can select the wrong slot to replace.
Look for an exact match first, before a free slot. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12272 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Mon Sep 19 07:12:00 CEST 2016 on sn-devel-144
This commit is contained in:
@ -504,10 +504,21 @@ static bool poll_funcs_context_slot_find(struct poll_funcs_state *state,
|
||||
size_t num_contexts = talloc_array_length(state->contexts);
|
||||
size_t i;
|
||||
|
||||
/* Look for an existing match first. */
|
||||
for (i=0; i<num_contexts; i++) {
|
||||
struct poll_funcs_tevent_context *ctx = state->contexts[i];
|
||||
|
||||
if ((ctx == NULL) || (ctx->ev == ev)) {
|
||||
if (ctx != NULL && ctx->ev == ev) {
|
||||
*slot = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Now look for a free slot. */
|
||||
for (i=0; i<num_contexts; i++) {
|
||||
struct poll_funcs_tevent_context *ctx = state->contexts[i];
|
||||
|
||||
if (ctx == NULL) {
|
||||
*slot = i;
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user