From 471fc1dfc8c9801aeeb2fa154e13e42c05fc9285 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 15 Oct 2018 12:27:35 +0200 Subject: [PATCH] Dive list: fix crash on dive import In commit 8c2383b4952fa22d41745d29484462ed6a67112b dive merging was changed to not modify the original dive. On import, dives were then merged and the original deleted. The merge_weightsystem_info() was not adapted accordingly (deep copy of string instead of pointer), leading to a use-after-free crash. Resolve this by doing a deep copy. Signed-off-by: Berthold Stoeger --- core/dive.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/dive.c b/core/dive.c index f44bfc3c1..5c3cd2393 100644 --- a/core/dive.c +++ b/core/dive.c @@ -2130,7 +2130,8 @@ static void merge_weightsystem_info(weightsystem_t *res, const weightsystem_t *a { if (!a->weight.grams) a = b; - *res = *a; + res->weight = a->weight; + res->description = copy_string(a->description); } /* get_cylinder_idx_by_use(): Find the index of the first cylinder with a particular CCR use type.