Commit 158b7148 by Marcus Winter

mtapi_c: fixed null potential null ptr dereference in id pool

parent 1d169817
...@@ -36,14 +36,19 @@ void embb_mtapi_id_pool_initialize( ...@@ -36,14 +36,19 @@ void embb_mtapi_id_pool_initialize(
mtapi_uint_t capacity) { mtapi_uint_t capacity) {
mtapi_uint_t ii; mtapi_uint_t ii;
that->capacity = capacity;
that->id_buffer = (mtapi_uint_t*) that->id_buffer = (mtapi_uint_t*)
embb_mtapi_alloc_allocate(sizeof(mtapi_uint_t)*(capacity + 1)); embb_mtapi_alloc_allocate(sizeof(mtapi_uint_t)*(capacity + 1));
if (NULL != that->id_buffer) {
that->capacity = capacity;
that->id_buffer[0] = EMBB_MTAPI_IDPOOL_INVALID_ID; that->id_buffer[0] = EMBB_MTAPI_IDPOOL_INVALID_ID;
for (ii = 1; ii <= capacity; ii++) { for (ii = 1; ii <= capacity; ii++) {
that->id_buffer[ii] = ii; that->id_buffer[ii] = ii;
} }
that->ids_available = capacity; that->ids_available = capacity;
} else {
that->capacity = 0;
that->ids_available = 0;
}
that->put_id_position = 0; that->put_id_position = 0;
that->get_id_position = 1; that->get_id_position = 1;
embb_spin_init(&that->lock); embb_spin_init(&that->lock);
......
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