From d7c9d57ba85e9e4e026e8feae8fc6f74b04bf4a4 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 15 Oct 2019 14:44:36 +0000 Subject: [PATCH] country: Fix segmentation fault when continent code is not set Signed-off-by: Michael Tremer --- src/country.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/country.c b/src/country.c index ee40d88..ca16c6d 100644 --- a/src/country.c +++ b/src/country.c @@ -159,8 +159,10 @@ int loc_country_to_database_v0(struct loc_country* country, } // Add continent code - for (unsigned int i = 0; i < 2; i++) { - dbobj->continent_code[i] = country->continent_code[i] ? country->continent_code[i] : '\0'; + if (country->continent_code) { + for (unsigned int i = 0; i < 2; i++) { + dbobj->continent_code[i] = country->continent_code[i] ? country->continent_code[i] : '\0'; + } } // Save the name string in the string pool -- 2.47.3