raster pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=64c1be2fba07cf1bbae1dc61a4ae3729f70a521f

commit 64c1be2fba07cf1bbae1dc61a4ae3729f70a521f
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
Date:   Thu Oct 15 18:16:57 2020 +0100

    e system - fix potential infinite loop with adding handlers
    
    dell handler inside handler func then add a new one ofr the same thing
    that does the same thing... infinite loop. only run hanlders after the
    loop of hanlders is handled by flagging as just_added and skip those
    (removing that flag after handlers list pass).
    
    @fix
---
 src/bin/e_system.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/bin/e_system.c b/src/bin/e_system.c
index 1e7aabb64..bfd43e7e2 100644
--- a/src/bin/e_system.c
+++ b/src/bin/e_system.c
@@ -11,6 +11,7 @@ typedef struct
    void (*func) (void *data, const char *params);
    void *data;
    Eina_Bool delete_me : 1;
+   Eina_Bool just_added : 1;
 } Handler;
 
 static Ecore_Exe *_system_exe = NULL;
@@ -163,7 +164,7 @@ _system_message_read(void)
         list = plist = eina_hash_find(_handlers, head->cmd);
         EINA_LIST_FOREACH(list, l, h)
           {
-             if (!h->delete_me)
+             if ((!h->delete_me) && (!h->just_added))
                {
                   if (head->size == 0) h->func(h->data, NULL);
                   else
@@ -179,6 +180,7 @@ _system_message_read(void)
           {
              EINA_LIST_FOREACH_SAFE(list, l, ll, h)
                {
+                  h->just_added = EINA_FALSE;
                   if (h->delete_me)
                     {
                        list = eina_list_remove_list(list, l);
@@ -376,6 +378,7 @@ e_system_handler_add(const char *cmd, void (*func) (void 
*data, const char *para
    if (!h) return;
    h->func = func;
    h->data = data;
+   if (_handlers_busy > 0) h->just_added = EINA_TRUE;
    list = eina_hash_find(_handlers, cmd);
    eina_hash_del(_handlers, cmd, list);
    list = eina_list_append(list, h);

-- 


Reply via email to