bu5hm4n pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=2dc5981034e66ab04c314f1586399e33aba9c484

commit 2dc5981034e66ab04c314f1586399e33aba9c484
Author: Marcel Hollerbach <[email protected]>
Date:   Sat Jan 28 23:50:52 2017 +0100

    gadgets: free that data when notify and main is done
    
    otherwise one of the two callbacks will use possible freed memory.
---
 src/modules/sysinfo/cpuclock/cpuclock.c   | 13 ++++++++++---
 src/modules/sysinfo/netstatus/netstatus.c | 11 +++++++++--
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/src/modules/sysinfo/cpuclock/cpuclock.c 
b/src/modules/sysinfo/cpuclock/cpuclock.c
index c1f3ac5..ef2e1b5 100644
--- a/src/modules/sysinfo/cpuclock/cpuclock.c
+++ b/src/modules/sysinfo/cpuclock/cpuclock.c
@@ -709,7 +709,6 @@ _cpuclock_cb_frequency_check_main(void *data, Ecore_Thread 
*th)
         if (ecore_thread_check(th)) break;
         usleep((1000000.0 / 8.0) * (double)thc->interval);
      }
-   E_FREE_FUNC(thc, free);
 }
 
 static void
@@ -750,6 +749,13 @@ _cpuclock_cb_frequency_check_notify(void *data,
                   inst->cfg->cpuclock.pstate_max - 1, 
inst->cfg->cpuclock.status->pstate_turbo);
 }
 
+static void
+_cpuclock_cb_frequency_check_end(void *data, Ecore_Thread *th EINA_UNUSED)
+{
+   Thread_Config *thc = data;
+   E_FREE_FUNC(thc, free);
+}
+
 void
 _cpuclock_poll_interval_update(Instance *inst)
 {
@@ -768,7 +774,8 @@ _cpuclock_poll_interval_update(Instance *inst)
         inst->cfg->cpuclock.frequency_check_thread =
           ecore_thread_feedback_run(_cpuclock_cb_frequency_check_main,
                                     _cpuclock_cb_frequency_check_notify,
-                                    NULL, NULL, thc, EINA_TRUE);
+                                    _cpuclock_cb_frequency_check_end,
+                                    _cpuclock_cb_frequency_check_end, thc, 
EINA_TRUE);
      }
    e_config_save_queue();
 }
@@ -844,7 +851,7 @@ _cpuclock_created_cb(void *data, Evas_Object *obj, void 
*event_data EINA_UNUSED)
    inst->cfg->cpuclock.status = _cpuclock_status_new();
    _cpuclock_status_check_available(inst->cfg->cpuclock.status);
    _cpuclock_poll_interval_update(inst);
-   inst->cfg->cpuclock.handler = 
ecore_event_handler_add(E_EVENT_POWERSAVE_UPDATE, 
+   inst->cfg->cpuclock.handler = 
ecore_event_handler_add(E_EVENT_POWERSAVE_UPDATE,
                                                _cpuclock_event_cb_powersave, 
inst);
    _cpuclock_config_updated(inst);
 }
diff --git a/src/modules/sysinfo/netstatus/netstatus.c 
b/src/modules/sysinfo/netstatus/netstatus.c
index d7292be..3513195 100644
--- a/src/modules/sysinfo/netstatus/netstatus.c
+++ b/src/modules/sysinfo/netstatus/netstatus.c
@@ -138,7 +138,6 @@ _netstatus_cb_usage_check_main(void *data, Ecore_Thread *th)
         if (ecore_thread_check(th)) break;
         usleep((1000000.0 / 8.0) * (double)thc->interval);
      }
-   E_FREE_FUNC(thc, free);
 }
 
 static void
@@ -155,6 +154,13 @@ _netstatus_cb_usage_check_notify(void *data,
    _netstatus_face_update(inst);
 }
 
+static void
+_netstatus_cb_usage_check_end(void *data, Ecore_Thread *th EINA_UNUSED)
+{
+   Thread_Config *thc = data;
+   E_FREE_FUNC(thc, free);
+}
+
 void
 _netstatus_config_updated(Instance *inst)
 {
@@ -173,7 +179,8 @@ _netstatus_config_updated(Instance *inst)
         inst->cfg->netstatus.usage_check_thread =
           ecore_thread_feedback_run(_netstatus_cb_usage_check_main,
                                     _netstatus_cb_usage_check_notify,
-                                    NULL, NULL, thc, EINA_TRUE);
+                                    _netstatus_cb_usage_check_end,
+                                    _netstatus_cb_usage_check_end, thc, 
EINA_TRUE);
      }
    e_config_save_queue();
 }

-- 


Reply via email to