summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/divelist.c8
-rw-r--r--core/divesite.c12
2 files changed, 12 insertions, 8 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.
diff --git a/core/divesite.c b/core/divesite.c
index ea9a3ed58..ee394d9d1 100644
--- a/core/divesite.c
+++ b/core/divesite.c
@@ -168,11 +168,13 @@ bool is_dive_site_used(uint32_t uuid, bool select_only)
void free_dive_site(struct dive_site *ds)
{
- free(ds->name);
- free(ds->notes);
- free(ds->description);
- free_taxonomy(&ds->taxonomy);
- free(ds);
+ if (ds) {
+ free(ds->name);
+ free(ds->notes);
+ free(ds->description);
+ free_taxonomy(&ds->taxonomy);
+ free(ds);
+ }
}
void delete_dive_site(uint32_t id)