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>
This commit is contained in:
Dirk Hohndel 2019-10-26 15:16:02 -04:00
parent 30566135aa
commit cc2269b9c5

View file

@ -246,12 +246,13 @@ void dive_end(struct parser_state *state)
{ {
if (!state->cur_dive) if (!state->cur_dive)
return; return;
if (!is_dive(state)) if (!is_dive(state)) {
free_dive(state->cur_dive); free_dive(state->cur_dive);
else } else {
record_dive_to_table(state->cur_dive, state->target_table); record_dive_to_table(state->cur_dive, state->target_table);
if (state->cur_trip) if (state->cur_trip)
add_dive_to_trip(state->cur_dive, state->cur_trip); add_dive_to_trip(state->cur_dive, state->cur_trip);
}
state->cur_dive = NULL; state->cur_dive = NULL;
state->cur_dc = NULL; state->cur_dc = NULL;
state->cur_location.lat.udeg = 0; state->cur_location.lat.udeg = 0;