[PATCH 1/3] Fix a crash on Liquivision import

Miika Turkia miika.turkia at gmail.com
Sun Mar 8 12:40:30 PDT 2015


Without the patch, there is a crash if the dive does not have a
location.

Signed-off-by: Miika Turkia <miika.turkia at gmail.com>
---
 liquivision.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/liquivision.c b/liquivision.c
index 7126c9b..2f1bb00 100644
--- a/liquivision.c
+++ b/liquivision.c
@@ -137,8 +137,12 @@ static void parse_dives (int log_version, const unsigned char *buf, unsigned int
 		} else if (place_len) {
 			location = strndup(buf + ptr + len + 4, place_len);
 		}
-		dive->dive_site_uuid = create_dive_site(location);
-		free(location);
+
+		/* Store the location only if we have one */
+		if (len || place_len) {
+			dive->dive_site_uuid = create_dive_site(location);
+			free(location);
+		}
 
 		ptr += len + 4 + place_len;
 
-- 
2.1.0



More information about the subsurface mailing list