Possible NULL Pointer Dereference
RootUp opened this issue · comments
Summary
Not sure but by looking at the code roughly, I see in the below code snippet if calloc fails due to insufficient memory or any other reasons, it will return NULL. If either allocation fails, the code attempt to dereference a NULL pointer.
// lazily allocate the memory for m_memory and v_memory
if (model->m_memory == NULL) {
model->m_memory = (float*)calloc(model->num_parameters, sizeof(float));
model->v_memory = (float*)calloc(model->num_parameters, sizeof(float));Fix: The ideal way is calloc should check or successfully allocate the memory before using the pointers.
Yes, this was reported already here. #10
Thanks, I missed that. Closing this.