summaryrefslogtreecommitdiffstats
path: root/core/parse-xml.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2017-02-19 14:11:37 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-02-19 15:23:46 -0800
commit4a550e4d7d5ec11640bb511d28097fa7644cdd3b (patch)
treef89ca8ee5c890a1d185a1f2c8aea8b3e1a0227b6 /core/parse-xml.c
parentfc55620d2d2942f7f8d95b5e73f8b58ec17ffdb9 (diff)
downloadsubsurface-4a550e4d7d5ec11640bb511d28097fa7644cdd3b.tar.gz
Properly handle dive sites loaded from XML
We used to always create a new dive site structure when loading dive site data from XML. That is completely bogus, because it can (and does) create duplicate dive sites with the same UUID. Which makes the whole UUID pointless. So instead, look up the existing dive site associated with the UUID loaded from the XML, and try to merge the data properly if we already had dive site information for that UUID. Reported-by: Alessandro Volpi <volpial@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'core/parse-xml.c')
-rw-r--r--core/parse-xml.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/core/parse-xml.c b/core/parse-xml.c
index 44cfece57..0032a5c32 100644
--- a/core/parse-xml.c
+++ b/core/parse-xml.c
@@ -1569,17 +1569,13 @@ static void dive_site_end(void)
{
if (!cur_dive_site)
return;
+ if (cur_dive_site->taxonomy.nr == 0) {
+ free(cur_dive_site->taxonomy.category);
+ cur_dive_site->taxonomy.category = NULL;
+ }
if (cur_dive_site->uuid) {
- // we intentionally call this with '0' to ensure we get
- // a new structure and then copy things into that new
- // structure a few lines below (which sets the correct
- // uuid)
- struct dive_site *ds = alloc_or_get_dive_site(0);
- if (cur_dive_site->taxonomy.nr == 0) {
- free(cur_dive_site->taxonomy.category);
- cur_dive_site->taxonomy.category = NULL;
- }
- copy_dive_site(cur_dive_site, ds);
+ struct dive_site *ds = alloc_or_get_dive_site(cur_dive_site->uuid);
+ merge_dive_site(ds, cur_dive_site);
if (verbose > 3)
printf("completed dive site uuid %x8 name {%s}\n", ds->uuid, ds->name);