From cc2269b9c5236b60b6a9c86588285f0a78836b77 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 26 Oct 2019 15:16:02 -0400 Subject: [PATCH] Cleanup: don't add invalid dive to trip Even if there is a valid trip, we should not add a structure that isn't a dive to it. Found by Coverity. Fixes CID #350073 Signed-off-by: Dirk Hohndel --- core/parse.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/parse.c b/core/parse.c index 6205c5afa..8344d3552 100644 --- a/core/parse.c +++ b/core/parse.c @@ -246,12 +246,13 @@ void dive_end(struct parser_state *state) { if (!state->cur_dive) return; - if (!is_dive(state)) + if (!is_dive(state)) { free_dive(state->cur_dive); - else + } else { record_dive_to_table(state->cur_dive, state->target_table); - if (state->cur_trip) - add_dive_to_trip(state->cur_dive, state->cur_trip); + if (state->cur_trip) + add_dive_to_trip(state->cur_dive, state->cur_trip); + } state->cur_dive = NULL; state->cur_dc = NULL; state->cur_location.lat.udeg = 0;