summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2019-03-14 01:23:19 +0100
committerBastien Nocera <hadess@hadess.net>2019-03-14 01:39:38 +0100
commite7216583a219df9d9eba21a7fe1b74543b6d5851 (patch)
treeadfdf4132284016f0104be79ba1e917794d3acbc
parent24d842347a294fe19393f95c3ce98cc5de9bcabe (diff)
downloadgeocode-glib-e7216583a219df9d9eba21a7fe1b74543b6d5851.tar.gz
geocode-nominatim: Fix possible crash with missing place_rank
Spotted by Ordissimo <thierry@ordissimo.com> Closes: #6
-rw-r--r--geocode-glib/geocode-nominatim.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/geocode-glib/geocode-nominatim.c b/geocode-glib/geocode-nominatim.c
index b2abc97..fc333dc 100644
--- a/geocode-glib/geocode-nominatim.c
+++ b/geocode-glib/geocode-nominatim.c
@@ -390,9 +390,11 @@ get_place_type_from_attributes (GHashTable *ht)
place_type = GEOCODE_PLACE_TYPE_DRAINAGE;
} else if (g_strcmp0 (category, "boundary") == 0) {
if (g_strcmp0 (type, "administrative") == 0) {
+ const char *place_rank;
int rank;
- rank = atoi (g_hash_table_lookup (ht, "place_rank"));
+ place_rank = g_hash_table_lookup (ht, "place_rank");
+ rank = place_rank ? atoi (place_rank) : 0;
if (rank < 2)
place_type = GEOCODE_PLACE_TYPE_UNKNOWN;