[geocode-glib/wip/hadess/place_rank-crasher: 1/2] geocode-nominatim: Fix possible crash with missing place_rank



commit e7216583a219df9d9eba21a7fe1b74543b6d5851
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Mar 14 01:23:19 2019 +0100

    geocode-nominatim: Fix possible crash with missing place_rank
    
    Spotted by Ordissimo <thierry ordissimo com>
    
    Closes: #6

 geocode-glib/geocode-nominatim.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
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;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]