summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Schmidt <s.schmidt@samsung.com>2020-06-16 11:03:26 +0200
committerStefan Schmidt <s.schmidt@samsung.com>2020-06-16 17:10:41 +0200
commit2b8742c0ab1ec1d129b1114ca21f23a149f44d87 (patch)
treea6998c529a5468e27f4a354b070a3b81204a9631
parente360ca4863b4ada144b69c2d092e01f056cadcfa (diff)
modules: eina: chained_pool: check for NULL before passing it to deref
Make sure we check if pool->first_fill is NULL before passing it onwards where it gets dereferenced. In case this happens return NULL instead of garbage. CID: 1293520 Reviewed-by: Christopher Michael <devilhorns@comcast.net> Differential Revision: https://phab.enlightenment.org/D11980
-rw-r--r--src/modules/eina/mp/chained_pool/eina_chained_mempool.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/modules/eina/mp/chained_pool/eina_chained_mempool.c b/src/modules/eina/mp/chained_pool/eina_chained_mempool.c
index 261b02c200..853457b684 100644
--- a/src/modules/eina/mp/chained_pool/eina_chained_mempool.c
+++ b/src/modules/eina/mp/chained_pool/eina_chained_mempool.c
@@ -274,7 +274,7 @@ eina_chained_mempool_malloc(void *data, EINA_UNUSED unsigned int size)
274{ 274{
275 Chained_Mempool *pool = data; 275 Chained_Mempool *pool = data;
276 Chained_Pool *p = NULL; 276 Chained_Pool *p = NULL;
277 void *mem; 277 void *mem = NULL;
278 278
279 if (!eina_spinlock_take(&pool->mutex)) 279 if (!eina_spinlock_take(&pool->mutex))
280 { 280 {
@@ -321,10 +321,10 @@ eina_chained_mempool_malloc(void *data, EINA_UNUSED unsigned int size)
321 _eina_chained_mp_pool_cmp, NULL); 321 _eina_chained_mp_pool_cmp, NULL);
322 } 322 }
323 323
324 mem = _eina_chained_mempool_alloc_in(pool, pool->first_fill); 324 if (pool->first_fill)
325 mem = _eina_chained_mempool_alloc_in(pool, pool->first_fill);
325 326
326 eina_spinlock_release(&pool->mutex); 327 eina_spinlock_release(&pool->mutex);
327
328 return mem; 328 return mem;
329} 329}
330 330