From 96a93c26db3151d55bea16b89ac6b832c55eb146 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Sat, 25 Dec 2010 20:27:19 +0100 Subject: [PATCH] Improve the detection of the last dive. --- src/mares_iconhd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mares_iconhd.c b/src/mares_iconhd.c index 28b3e2d..7bb9959 100644 --- a/src/mares_iconhd.c +++ b/src/mares_iconhd.c @@ -345,6 +345,8 @@ mares_iconhd_extract_dives (device_t *abstract, const unsigned char data[], unsi while (offset >= 0x60) { // Get the number of samples in the profile data. unsigned int nsamples = array_uint16_le (buffer + offset - 0x5A); + if (nsamples == 0xFFFF) + break; // Calculate the total number of bytes for this dive. // If the buffer does not contain that much bytes, we reached the @@ -361,6 +363,8 @@ mares_iconhd_extract_dives (device_t *abstract, const unsigned char data[], unsi // equals the calculated length. If both values are different, // something is wrong and an error is returned. unsigned int length = array_uint32_le (buffer + offset); + if (length == 0) + break; if (length != nbytes) { WARNING ("Calculated and stored size are not equal."); free (buffer);