diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-09-29 12:58:16 -0400 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-09-29 12:58:16 -0400 |
commit | edac07554c50a693389e4d88a6d6f56820c940f1 (patch) | |
tree | 4926b2f0b2e846690f1270265d60f61856d9bffc /parse-xml.c | |
parent | 7ad1485c398b8bea651e28acb5eed2c78ff8a18e (diff) | |
download | subsurface-edac07554c50a693389e4d88a6d6f56820c940f1.tar.gz |
Make sure we don't create multiple dive sites with the same uuid
This shouldn't happen, but in case there is a logic error higher up in the
code somewhere, this will prevent it from happening, period.
If the code asks for a new dive site with a specific uuid, simply return
the existing dive site with that uuid.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r-- | parse-xml.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/parse-xml.c b/parse-xml.c index be5215509..9b223980d 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -1562,7 +1562,11 @@ static void dive_site_end(void) if (!cur_dive_site) return; if (cur_dive_site->uuid) { - struct dive_site *ds = alloc_dive_site(0); + // 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; |