Finish immediately if there are no dives available.
When trying to continue when no dives are available, malloc() will be called to allocate zero bytes. The result is implementation defined and may return a NULL pointer. Since that would be interpreted as an error, it's safer to finish immediately.
This commit is contained in:
parent
f4eeb7745e
commit
9366e36309
@ -418,6 +418,12 @@ hw_frog_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void
|
||||
progress.maximum = (RB_LOGBOOK_SIZE * RB_LOGBOOK_COUNT) + size;
|
||||
device_event_emit (abstract, DC_EVENT_PROGRESS, &progress);
|
||||
|
||||
// Finish immediately if there are no dives available.
|
||||
if (ndives == 0) {
|
||||
free (header);
|
||||
return DC_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Allocate enough memory for the largest dive.
|
||||
unsigned char *profile = malloc (maxsize);
|
||||
if (profile == NULL) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user