From 39aad6bb52d4ed6e8d5c224798f4f471d90a9f19 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Tue, 18 Feb 2020 22:17:12 +0100 Subject: [PATCH] Report an error for invalid ringbuffer pointers Previously, invalid ringbuffer pointers were always handled during the second pass. But that changed after the previous commit. If the invalid pointer is located in the first logbook entry, this is now handled as "no dives present". Fixed by returning the correct error code instead. --- src/oceanic_common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/oceanic_common.c b/src/oceanic_common.c index 728101f..48ed61a 100644 --- a/src/oceanic_common.c +++ b/src/oceanic_common.c @@ -330,6 +330,7 @@ dc_status_t oceanic_common_device_profile (dc_device_t *abstract, dc_event_progress_t *progress, dc_buffer_t *logbook, dc_dive_callback_t callback, void *userdata) { oceanic_common_device_t *device = (oceanic_common_device_t *) abstract; + dc_status_t status = DC_STATUS_SUCCESS; dc_status_t rc = DC_STATUS_SUCCESS; assert (device != NULL); @@ -379,6 +380,7 @@ oceanic_common_device_profile (dc_device_t *abstract, dc_event_progress_t *progr { ERROR (abstract->context, "Invalid ringbuffer pointer detected (0x%06x 0x%06x).", rb_entry_first, rb_entry_last); + status = DC_STATUS_DATAFORMAT; break; } @@ -419,7 +421,7 @@ oceanic_common_device_profile (dc_device_t *abstract, dc_event_progress_t *progr // Exit if there are no dives. if (rb_profile_size == 0) { - return DC_STATUS_SUCCESS; + return status; } // Create the ringbuffer stream.