From: Michael Tremer Date: Tue, 15 Oct 2019 14:44:36 +0000 (+0000) Subject: country: Fix segmentation fault when continent code is not set X-Git-Tag: 0.9.0~32 X-Git-Url: http://git.ipfire.org/?p=people%2Fms%2Flibloc.git;a=commitdiff_plain;h=d7c9d57ba85e9e4e026e8feae8fc6f74b04bf4a4 country: Fix segmentation fault when continent code is not set Signed-off-by: Michael Tremer --- 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