From 80e6032f6fd57ea73bc4d7eab48277ec500f02a3 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 5 Oct 2017 15:40:19 -0700 Subject: Prevent crash when adding country to dive site We need to make sure that the taxonomy information has been allocated before assigning values to it... Signed-off-by: Dirk Hohndel --- core/taxonomy.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'core') diff --git a/core/taxonomy.c b/core/taxonomy.c index a6d829fa1..8776862d6 100644 --- a/core/taxonomy.c +++ b/core/taxonomy.c @@ -61,6 +61,11 @@ const char *taxonomy_get_country(struct taxonomy_data *t) void taxonomy_set_country(struct taxonomy_data *t, const char *country, enum taxonomy_origin origin) { int idx = -1; + + // make sure we have taxonomy data allocated + if (!t->category) + t->category = alloc_taxonomy(); + for (int i = 0; i < t->nr; i++) { if (t->category[i].category == TC_COUNTRY) { idx = i; -- cgit v1.2.3-70-g09d2