elementary: prevent double free
authorJean Guyomarc'h <jean.guyomarch@openwide.fr>
Fri, 26 Aug 2016 13:04:37 +0000 (15:04 +0200)
committerJean Guyomarc'h <jean@guyomarch.bzh>
Fri, 26 Aug 2016 19:16:39 +0000 (21:16 +0200)
This one is a bit tricky... When we create the aggregated
promise, if one of the properties of the model returns an
error, the eina_promise_then() will immediately call the
error callback. In this happened for the first item, the
total items in the listing request would be 1.

Before this commit, we tested for incremented the processed
counter and compared it to this total count. If it was
greater or equal, we would free the common listing request.
But in the case of successive failures, we would set the
total counter to 1, then the processed counter to 1 and
therefore free. Then increment the total counter to 2, then
then processed counter to 2, and free again... which would
cause an abort() from the libc or something else nasty.

Now we just decrease the total count of items. We avoid
the cases and double frees, without leaking.

src/lib/elementary/elc_fileselector.c

index 81b6ba2..8ed2894 100644 (file)
@@ -774,17 +774,7 @@ _process_child_error_cb(void *data, Eina_Error err EINA_UNUSED)
 
    WRN("could not get data from child Efl.Model");
 
-   ++(lreq->item_processed_count);
-   if (lreq->item_processed_count >= lreq->item_total)
-     {
-        if (!lreq->valid)
-          {
-             _listing_request_cleanup(lreq);
-             return;
-          }
-        _signal_first(lreq);
-        _process_last(lreq);
-     }
+   lreq->item_total--;
 }
 
 static void