eo: set idx on exit to 1 not to 0

if this is set to 0 the next iteration in the upper frame event would
decrement the 0 again leading to a overflow making the iteration and
callback array overflow.

Long story short: set ifx to 1 to prevent overflow, test added.

fixes T8787

Differential Revision: https://phab.enlightenment.org/D12101
This commit is contained in:
Marcel Hollerbach 2020-08-10 10:43:18 +02:00
parent a923cb0f7b
commit 812e9f9f09
2 changed files with 33 additions and 2 deletions

View File

@ -2146,7 +2146,9 @@ restart_back:
end:
// Handling restarting list walking complete exit.
if (restart_lookup) restart_lookup->idx = 0;
// This must be 1, we copy back the frame idx at the end of the for loop.
// The next iteration then decrements the idx by 1 which results in the effective running idx of that frame beeing 0
if (restart_lookup) restart_lookup->idx = 1;
EVENT_STACK_POP(pd);

View File

@ -74,6 +74,22 @@ _restart_3_cb(void *data, const Efl_Event *event)
called++;
}
static void
_restart_3_no_stop_cb(void *data, const Efl_Event *event)
{
fprintf(stderr, "restart 3 no stop inside: %i\n", inside);
fprintf(stderr, "restart 3 no stop exit inside: %i (%i)\n", inside, called);
if (!inside)
{
inside = EINA_TRUE;
efl_event_callback_call(event->object, event->desc, data);
inside = EINA_FALSE;
}
called++;
}
int
main(int argc, char *argv[])
{
@ -219,8 +235,21 @@ main(int argc, char *argv[])
efl_event_callback_legacy_call(obj, EV_RESTART, NULL);
fail_if(inside);
fail_if(called != 3);
efl_unref(obj);
pd = NULL;
inside = EINA_FALSE;
called = 0;
obj = efl_add_ref(SIMPLE_CLASS, NULL);
efl_event_callback_add(obj, EV_RESTART, _restart_3_no_stop_cb, NULL);
efl_event_callback_add(obj, EV_RESTART, _null_cb, NULL);
efl_event_callback_add(obj, EV_RESTART, _restart_3_no_stop_cb, NULL);
efl_event_callback_call(obj, EV_RESTART, NULL);
fail_if(inside);
fail_if(called != 2);
efl_object_shutdown();
return 0;
}