[PATCH v2 0/3] MR8804: server: Return NULL from get_first_valid_hook when no hook is found.
Fixes: 5b7b76432dffa453e75c6336d76fdb856ab8d0c7 -- v2: server: Use LIST_FOR_EACH_ENTRY in get_next_hook. server: Return NULL from get_next_hook when no hook is found. https://gitlab.winehq.org/wine/wine/-/merge_requests/8804
From: Rémi Bernon <rbernon(a)codeweavers.com> Fixes: 5b7b76432dffa453e75c6336d76fdb856ab8d0c7 --- server/hook.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/hook.c b/server/hook.c index e0281d92b81..688174baab5 100644 --- a/server/hook.c +++ b/server/hook.c @@ -257,7 +257,7 @@ static inline struct hook *get_first_valid_hook( struct hook_table *table, int i } } } - return hook; + return NULL; } /* find the next hook in the chain, skipping the deleted ones */ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/8804
From: Rémi Bernon <rbernon(a)codeweavers.com> Fixes: 5b7b76432dffa453e75c6336d76fdb856ab8d0c7 --- server/hook.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/server/hook.c b/server/hook.c index 688174baab5..d04b784b0b3 100644 --- a/server/hook.c +++ b/server/hook.c @@ -285,12 +285,9 @@ static struct hook *get_next_hook( struct thread *thread, struct hook *hook, int } } } - global_hooks = get_global_hooks( thread ); - if (global_hooks && table != global_hooks) /* now search through the global table */ - { - hook = get_first_valid_hook( global_hooks, index, event, win, object_id, child_id ); - } - return hook; + + if (!(global_hooks = get_global_hooks( thread )) || table == global_hooks) return NULL; + return get_first_valid_hook( global_hooks, index, event, win, object_id, child_id ); } static void hook_table_dump( struct object *obj, int verbose ) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/8804
From: Rémi Bernon <rbernon(a)codeweavers.com> --- server/hook.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/server/hook.c b/server/hook.c index d04b784b0b3..7fd86226f7d 100644 --- a/server/hook.c +++ b/server/hook.c @@ -265,12 +265,10 @@ static struct hook *get_next_hook( struct thread *thread, struct hook *hook, int user_handle_t win, int object_id, int child_id ) { struct hook_table *global_hooks, *table = hook->table; - struct list *ptr; int index = hook->index; - while ((ptr = list_next( &table->hooks[index], &hook->chain ))) + LIST_FOR_EACH_ENTRY( hook, &table->hooks[index], struct hook, chain ) { - hook = LIST_ENTRY( ptr, struct hook, chain ); if (hook->proc && run_hook_in_current_thread( hook )) { if (event >= hook->event_min && event <= hook->event_max) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/8804
v2: Add another fix for get_next_hook which was also broken by the same change: if hook table is empty, it may return hook pointer instead of NULL as was the case before. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/8804#note_113392
Well I guess the test failures look quite bad, there's probably more issues, either from this fix or from 5b7b76432dffa453e75c6336d76fdb856ab8d0c7 in the first place. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/8804#note_113397
participants (1)
-
Rémi Bernon