[PATCH] Check if trip is NULL before calling DIVE_TRIP
Dirk Hohndel
dirk at hohndel.org
Wed Sep 19 10:49:37 PDT 2012
"Lubomir I. Ivanov" <neolit123 at gmail.com> writes:
> From: "Lubomir I. Ivanov" <neolit123 at gmail.com>
>
> Other places have this check, but for this particular one a crash
> can be reproduced:
>
> ./subsurface ./dives/*
> log -> autogroup
> log -> autogroup
>
> Against d14932058f191de2a
>
> Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
> ---
> divelist.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/divelist.c b/divelist.c
> index f032e62..909e27b 100644
> --- a/divelist.c
> +++ b/divelist.c
> @@ -1067,7 +1067,8 @@ static void fill_dive_list(void)
> }
> } else if (DIVE_IN_TRIP(dive)) {
> trip = find_matching_trip(dive->when);
> - dive_trip = DIVE_TRIP(trip);
> + if (trip)
> + dive_trip = DIVE_TRIP(trip);
> } else {
> /* dive is not in a trip and we aren't autogrouping */
> dive_trip = NULL;
Yes, this is a valid check. But I wonder... if DIVE_IN_TRIP(dive) is
true, then we SHOULD have a matching trip so trip should never be NULL
(which is why I didn't have the check). So I'll need figure out why we
get trip=NULL to begin with.
/D
More information about the subsurface
mailing list