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 <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2017-10-05 15:40:19 -07:00
parent 3487612337
commit 80e6032f6f

View file

@ -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;