From 763c3683e58684f296d6b66835ca6d84e14b3900 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 15 Oct 2018 21:58:30 +0200 Subject: [PATCH] Core: fix broken commit e5dca8228e In commit e5dca8228e6b60cac5957726700c66d0565c064e a fixed order of the arguments to merge_dives() was introduced: first dive old, second dive downloaded. This made the dl variable, which pointed to the downloaded dive useless. One instance was forgotten, which led to a null-dereference. Remove. Reported-by: Dirk Hohndel Signed-off-by: Berthold Stoeger Signed-off-by: Dirk Hohndel --- core/dive.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/dive.c b/core/dive.c index 1fe3eccf4..345b59c2c 100644 --- a/core/dive.c +++ b/core/dive.c @@ -3438,7 +3438,6 @@ int count_dives_with_suit(const char *suit) struct dive *merge_dives(const struct dive *a, const struct dive *b, int offset, bool prefer_downloaded, struct dive_trip **trip) { struct dive *res = alloc_dive(); - const struct dive *dl = NULL; const struct dive *preferred_trip; int cylinders_map_a[MAX_CYLINDERS], cylinders_map_b[MAX_CYLINDERS]; @@ -3480,7 +3479,7 @@ struct dive *merge_dives(const struct dive *a, const struct dive *b, int offset, merge_temperatures(res, a, b); if (prefer_downloaded) { /* If we prefer downloaded, do those first, and get rid of "might be same" computers */ - join_dive_computers(res, &res->dc, &dl->dc, &a->dc, cylinders_map_b, cylinders_map_a, 1); + join_dive_computers(res, &res->dc, &b->dc, &a->dc, cylinders_map_b, cylinders_map_a, 1); } else if (offset && might_be_same_device(&a->dc, &b->dc)) interleave_dive_computers(res, &res->dc, &a->dc, &b->dc, cylinders_map_a, cylinders_map_b, offset); else