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)
commit0874c4da3823ceae0dfcda44b0e0d5e6251e39a9
treeae6d47fb97e48d062d59613f48248b361ad29e7b
parent322adb2e035fec05de109568934a013afe0b9edb
elementary: prevent double free

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