mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Fix "prefer downloaded" dive sample merging case
When we have a preferred dive computer that overrides old information when merging two dives, we just copy the dive computer data over. However, we need to clear the source of the dive computer data so that we then don't free the sample data when that old source of the newly merged dive gets free'd. This fixes a memory scribble (and likely SIGSEGV) for the "prefer downloaded" case. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
27f7e58493
commit
8d62f20aa0
1 changed files with 7 additions and 0 deletions
7
dive.c
7
dive.c
|
@ -1103,6 +1103,13 @@ struct dive *merge_dives(struct dive *a, struct dive *b, int offset, gboolean pr
|
|||
merge_equipment(res, a, b);
|
||||
if (dl) {
|
||||
res->dc = dl->dc;
|
||||
/*
|
||||
* Since we copied the events and samples,
|
||||
* we can't free them from the source when
|
||||
* we free it - so make sure the source
|
||||
* dive computer data is cleared out.
|
||||
*/
|
||||
memset(&dl->dc, 0, sizeof(dl->dc));
|
||||
} else {
|
||||
merge_events(&res->dc, &a->dc, &b->dc, offset);
|
||||
merge_samples(&res->dc, &a->dc, &b->dc, offset);
|
||||
|
|
Loading…
Add table
Reference in a new issue