ARTEMIS-2260 Prevent a null pointer dereference if unable to allocate memory for the

events member of the control structure. This could also cause the broker
to abruptly shutdown.
This commit is contained in:
Otavio Rodolfo Piske 2019-01-29 14:37:08 +01:00 committed by Clebert Suconic
parent 584a610f6a
commit 6dafedb6af
1 changed files with 6 additions and 0 deletions

View File

@ -421,6 +421,12 @@ JNIEXPORT jobject JNICALL Java_org_apache_activemq_artemis_jlibaio_LibaioContext
}
struct io_event * events = (struct io_event *)malloc(sizeof(struct io_event) * (size_t)queueSize);
if (events == NULL) {
free(theControl);
free(libaioContext);
throwRuntimeExceptionErrorNo(env, "Can't initialize mutext (not enough memory for the events member): ", res);
return NULL;
}
theControl->ioContext = libaioContext;
theControl->events = events;