From: Jean Guyomarc'h Date: Sat, 16 Sep 2017 12:17:25 +0000 (+0200) Subject: eina: handle errors when creating a mempool X-Git-Tag: submit/sandbox/upgrade/efl120/20180319.053334~2639 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ca731fbfb6aa1ab376846870f1a4260b27bdf793;p=platform%2Fupstream%2Fefl.git eina: handle errors when creating a mempool If the backend initialization failed, the mempool would still be successfully created. The mempool is now destroyed on failure. --- diff --git a/src/lib/eina/eina_mempool.c b/src/lib/eina/eina_mempool.c index b72dadb..a6d0d18 100644 --- a/src/lib/eina/eina_mempool.c +++ b/src/lib/eina/eina_mempool.c @@ -65,8 +65,8 @@ _new_va(const char *name, const char *options, va_list args) { - Eina_Mempool_Backend *be = NULL; - Eina_Mempool *mp; + Eina_Mempool_Backend *be; + Eina_Mempool *mp = NULL; if (getenv("EINA_MEMPOOL_PASS")) { @@ -100,9 +100,13 @@ _new_va(const char *name, } mp->backend_data = mp->backend.init(context, options, args); + if (EINA_UNLIKELY(! mp->backend_data)) goto clean_mp; return mp; +clean_mp: + free(mp->backend2); on_error: + free(mp); return NULL; }