Prevent a zero length memory allocation.

In theory this shouldn't be possible, but it doesn't hurt to check the
length explicitely.
This commit is contained in:
Jef Driesen 2015-07-12 22:13:22 +02:00
parent 76bd9783d4
commit 4795e1b6ce

View File

@ -315,6 +315,11 @@ oceanic_common_device_foreach (dc_device_t *abstract, dc_dive_callback_t callbac
rb_logbook_page_size;
device_event_emit (abstract, DC_EVENT_PROGRESS, &progress);
// Exit if there are no dives.
if (rb_logbook_page_size == 0) {
return DC_STATUS_SUCCESS;
}
// Memory buffer for the logbook entries.
unsigned char *logbooks = (unsigned char *) malloc (rb_logbook_page_size);
if (logbooks == NULL)