summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2019-10-26 15:16:02 -0400
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-10-26 19:17:53 -0700
commitcc2269b9c5236b60b6a9c86588285f0a78836b77 (patch)
tree5b6964653454c5edc55da8eaf16bd51a988299bc /core
parent30566135aa8b9fa75b071a2b23927db33aea63b5 (diff)
downloadsubsurface-cc2269b9c5236b60b6a9c86588285f0a78836b77.tar.gz
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 <dirk@hohndel.org>
Diffstat (limited to 'core')
-rw-r--r--core/parse.c9
1 files 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;