]> git.ipfire.org Git - people/ms/libloc.git/blobdiff - src/country-list.c
countries: Fix matching invalid country codes
[people/ms/libloc.git] / src / country-list.c
index cc367405295e0eaa0099091fcf0b9824a8acf531..103536cdc52f2d7599734c1310622c867dc54258 100644 (file)
@@ -151,8 +151,13 @@ LOC_EXPORT int loc_country_list_contains_code(
        struct loc_country* country;
 
        int r = loc_country_new(list->ctx, &country, code);
-       if (r)
-               return -1;
+       if (r) {
+               // Ignore invalid country codes which would never match
+               if (errno == EINVAL)
+                       return 0;
+               else
+                       return r;
+       }
 
        r = loc_country_list_contains(list, country);
        loc_country_unref(country);