eina: don't access dead promise.
authorCedric BAIL <cedric@osg.samsung.com>
Tue, 31 May 2016 21:18:48 +0000 (14:18 -0700)
committerCedric BAIL <cedric@osg.samsung.com>
Tue, 31 May 2016 21:59:26 +0000 (14:59 -0700)
We do properly unref promise while calling all the then callback. There
is no need to check it a second time (which actually lead to a 100%
bad access).

T3759

src/lib/eina/eina_promise.c

index 2b3f154..a39e52e 100644 (file)
@@ -167,14 +167,14 @@ _eina_promise_then_calls(_Eina_Promise_Default_Owner* promise)
      {
        promise->promise.then_callbacks = eina_inlist_remove(promise->promise.then_callbacks, EINA_INLIST_GET(callback));
        if (error)
-        {
-          if (callback->error_cb)
-            (*callback->error_cb)(callback->data, promise->promise.error, &promise->promise.vtable);
-        }
+         {
+            if (callback->error_cb)
+              (*callback->error_cb)(callback->data, promise->promise.error, &promise->promise.vtable);
+         }
        else if (callback->callback)
-        {
-          (*callback->callback)(callback->data, &promise->value[0], &promise->promise.vtable);
-        }
+         {
+            (*callback->callback)(callback->data, &promise->value[0], &promise->promise.vtable);
+         }
        free(callback);
        _eina_promise_unref(&promise->promise);
      }
@@ -327,10 +327,6 @@ _eina_promise_finish(_Eina_Promise_Default_Owner* promise)
      {
         _eina_promise_then_calls(promise);
      }
-   if(promise->promise.ref == 0)
-     {
-        _eina_promise_del(promise);
-     }
 }
 
 static Eina_Error