summaryrefslogtreecommitdiffstats
path: root/core/divelist.c
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-10-21 21:48:47 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-10-23 08:06:17 +0100
commit343808271c22942992f4470c05e138d8597a630b (patch)
tree61df6531dc70c03fee2bfc03e1e806f896822e50 /core/divelist.c
parent46bf8bf2fa37f1aae44241a5f7d846810041aac9 (diff)
downloadsubsurface-343808271c22942992f4470c05e138d8597a630b.tar.gz
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 <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/divelist.c')
-rw-r--r--core/divelist.c8
1 files changed, 5 insertions, 3 deletions
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.