bu5hm4n pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=812e9f9f09e4789284536ea7fc10634e0c1148b7

commit 812e9f9f09e4789284536ea7fc10634e0c1148b7
Author: Marcel Hollerbach <[email protected]>
Date:   Mon Aug 10 10:43:18 2020 +0200

    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
---
 src/lib/eo/eo_base_class.c          |  4 +++-
 src/tests/eo/signals/signals_main.c | 31 ++++++++++++++++++++++++++++++-
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c
index bd394910c9..e7445021bd 100644
--- a/src/lib/eo/eo_base_class.c
+++ b/src/lib/eo/eo_base_class.c
@@ -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);
 
diff --git a/src/tests/eo/signals/signals_main.c 
b/src/tests/eo/signals/signals_main.c
index c3b1648c17..859e145ecb 100644
--- a/src/tests/eo/signals/signals_main.c
+++ b/src/tests/eo/signals/signals_main.c
@@ -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;
 }

-- 


Reply via email to