ecore: fix a potential memory leak.
authorHermet Park <hermetpark@gmail.com>
Mon, 9 Apr 2018 02:46:13 +0000 (11:46 +0900)
committerWonki Kim <wonki_.kim@samsung.com>
Tue, 10 Apr 2018 13:26:06 +0000 (22:26 +0900)
if the func argument is null, allocated memory won't be freed properly.
return it as soon as possible.

@fix

src/lib/ecore/ecore_timer.c

index b1b9a99..ed75b05 100644 (file)
@@ -197,13 +197,13 @@ ecore_timer_loop_add(double in, Ecore_Task_Cb func, const void  *data)
    Eo *timer;
 
    EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
-   legacy = calloc(1, sizeof (Ecore_Timer_Legacy));
-   if (!legacy) return NULL;
    if (!func)
      {
         ERR("Callback function must be set up for the class.");
         return NULL;
      }
+   legacy = calloc(1, sizeof (Ecore_Timer_Legacy));
+   if (!legacy) return NULL;
    legacy->func = func;
    legacy->data = data;
    timer = efl_add(MY_CLASS, efl_main_loop_get(),