]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
country: Fix segmentation fault when continent code is not set
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 15 Oct 2019 14:44:36 +0000 (14:44 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 15 Oct 2019 14:44:36 +0000 (14:44 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/country.c

index ee40d888b576d38f575b9e57a79f122116aafa1e..ca16c6db430bc1c43085eb3fd442268432e04ca9 100644 (file)
@@ -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