Commit c0ae08cf by Marcus Winter

mtapi_c: fixed potential null ptr dereference in pool template

parent 158b7148
...@@ -61,6 +61,7 @@ mtapi_boolean_t embb_mtapi_##TYPE##_pool_initialize( \ ...@@ -61,6 +61,7 @@ mtapi_boolean_t embb_mtapi_##TYPE##_pool_initialize( \
embb_mtapi_id_pool_initialize(&that->id_pool, capacity); \ embb_mtapi_id_pool_initialize(&that->id_pool, capacity); \
that->storage = (embb_mtapi_##TYPE##_t*)embb_mtapi_alloc_allocate( \ that->storage = (embb_mtapi_##TYPE##_t*)embb_mtapi_alloc_allocate( \
sizeof(embb_mtapi_##TYPE##_t)*(capacity + 1)); \ sizeof(embb_mtapi_##TYPE##_t)*(capacity + 1)); \
if (NULL != that->storage) { \
for (ii = 0; ii <= capacity; ii++) { \ for (ii = 0; ii <= capacity; ii++) { \
that->storage[ii].handle.id = EMBB_MTAPI_IDPOOL_INVALID_ID; \ that->storage[ii].handle.id = EMBB_MTAPI_IDPOOL_INVALID_ID; \
that->storage[ii].handle.tag = 0; \ that->storage[ii].handle.tag = 0; \
...@@ -68,6 +69,10 @@ mtapi_boolean_t embb_mtapi_##TYPE##_pool_initialize( \ ...@@ -68,6 +69,10 @@ mtapi_boolean_t embb_mtapi_##TYPE##_pool_initialize( \
/* use entry 0 as invalid */ \ /* use entry 0 as invalid */ \
embb_mtapi_##TYPE##_initialize(that->storage); \ embb_mtapi_##TYPE##_initialize(that->storage); \
return MTAPI_TRUE; \ return MTAPI_TRUE; \
} else { \
that->id_pool.ids_available = 0; \
return MTAPI_FALSE; \
} \
} \ } \
\ \
void embb_mtapi_##TYPE##_pool_finalize(embb_mtapi_##TYPE##_pool_t * that) { \ void embb_mtapi_##TYPE##_pool_finalize(embb_mtapi_##TYPE##_pool_t * that) { \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment