Evas Device: use EINA_LIST_FOREACH_SAFE instead of EINA_LIST_FREE 28/70228/3
authorDuna Oh <duna.oh@samsung.com>
Thu, 19 May 2016 01:58:36 +0000 (10:58 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Thu, 19 May 2016 02:21:27 +0000 (19:21 -0700)
evas_device_del does eina_list_remove, and EINA_LIST_FREE does the same thing.
It can causes memory leak and possible crash. (reported by valgrind)

Signed-off-by: Duna Oh <duna.oh@samsung.com>
Change-Id: I2166f1eb4672ffe65dd961d608557018ade1cae0

src/lib/evas/canvas/evas_device.c

index effed55..68c743b 100644 (file)
@@ -242,6 +242,7 @@ void
 _evas_device_cleanup(Evas *eo_e)
 {
    Evas_Device *dev;
+   Eina_List *l1, *l2;
    
    Evas_Public_Data *e = eo_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
    if (e->cur_device)
@@ -251,9 +252,10 @@ _evas_device_cleanup(Evas *eo_e)
         eina_array_free(e->cur_device);
         e->cur_device = NULL;
      }
-   EINA_LIST_FREE(e->devices, dev)
+   EINA_LIST_FOREACH_SAFE(e->devices, l1, l2, dev)
      {
-        evas_device_del(dev);
+        while (dev)
+          evas_device_del(dev);
      }
 }