summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Guyomarc'h <jean@guyomarch.bzh>2017-09-16 14:17:25 +0200
committerJean Guyomarc'h <jean@guyomarch.bzh>2017-09-16 14:28:39 +0200
commitca731fbfb6aa1ab376846870f1a4260b27bdf793 (patch)
tree07b5f86cceb531032d236305c36321379f8575d6
parentb5c4aeab94b276e001819d22cc684a71caff564a (diff)
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.
-rw-r--r--src/lib/eina/eina_mempool.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/lib/eina/eina_mempool.c b/src/lib/eina/eina_mempool.c
index b72dadbce6..a6d0d18fe2 100644
--- a/src/lib/eina/eina_mempool.c
+++ b/src/lib/eina/eina_mempool.c
@@ -65,8 +65,8 @@ _new_va(const char *name,
65 const char *options, 65 const char *options,
66 va_list args) 66 va_list args)
67{ 67{
68 Eina_Mempool_Backend *be = NULL; 68 Eina_Mempool_Backend *be;
69 Eina_Mempool *mp; 69 Eina_Mempool *mp = NULL;
70 70
71 if (getenv("EINA_MEMPOOL_PASS")) 71 if (getenv("EINA_MEMPOOL_PASS"))
72 { 72 {
@@ -100,9 +100,13 @@ _new_va(const char *name,
100 } 100 }
101 101
102 mp->backend_data = mp->backend.init(context, options, args); 102 mp->backend_data = mp->backend.init(context, options, args);
103 if (EINA_UNLIKELY(! mp->backend_data)) goto clean_mp;
103 return mp; 104 return mp;
104 105
106clean_mp:
107 free(mp->backend2);
105on_error: 108on_error:
109 free(mp);
106 return NULL; 110 return NULL;
107} 111}
108 112