diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-07-13 07:09:55 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-07-13 07:09:55 -0700 |
commit | 3478943f2ff5fae36d59667ffed33b9494d22acd (patch) | |
tree | 55271a007c085c1897563e9ec79a42ca570ed53c /divesite.c | |
parent | 15de7f0b716b4e3c28fee4f4ccbac4788a8d84b1 (diff) | |
download | subsurface-3478943f2ff5fae36d59667ffed33b9494d22acd.tar.gz |
Fix memory handling for taxonomy data
The way we freed things and cleared out the variables potentially left
dangling data behind and could end up calling free on garbage data,
leading to random crashes.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'divesite.c')
-rw-r--r-- | divesite.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/divesite.c b/divesite.c index 5c96bb2dd..998fe23bf 100644 --- a/divesite.c +++ b/divesite.c @@ -170,9 +170,7 @@ void copy_dive_site(struct dive_site *orig, struct dive_site *copy) copy->description = copy_string(orig->description); copy->uuid = orig->uuid; if (orig->taxonomy.category == NULL) { - free_taxonomy(copy->taxonomy.category); - copy->taxonomy.category = NULL; - copy->taxonomy.nr = 0; + free_taxonomy(©->taxonomy); } else { if (copy->taxonomy.category == NULL) copy->taxonomy.category = alloc_taxonomy(); @@ -200,6 +198,5 @@ void clear_dive_site(struct dive_site *ds) ds->longitude.udeg = 0; ds->uuid = 0; ds->taxonomy.nr = 0; - free_taxonomy(ds->taxonomy.category); - ds->taxonomy.category = NULL; + free_taxonomy(&ds->taxonomy); } |