From 343808271c22942992f4470c05e138d8597a630b Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 21 Oct 2018 21:48:47 +0200 Subject: Core: accept NULL-pointer in free_trip() and free_divesite() This is consistent with most other free_*() functions in the core code and will make cleanup of parser state less verbose. Signed-off-by: Berthold Stoeger --- core/divelist.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'core/divelist.c') diff --git a/core/divelist.c b/core/divelist.c index 0722953ae..88cf5645d 100644 --- a/core/divelist.c +++ b/core/divelist.c @@ -765,9 +765,11 @@ void insert_trip_dont_merge(dive_trip_t *dive_trip) /* free resources associated with a trip structure */ void free_trip(dive_trip_t *trip) { - free(trip->location); - free(trip->notes); - free(trip); + if (trip) { + free(trip->location); + free(trip->notes); + free(trip); + } } /* remove trip from the trip-list, but don't free its memory. -- cgit v1.2.3-70-g09d2