]> git.street.me.uk Git - andy/viking.git/commitdiff
Prevention of crashing in mapcache when tmp variable is NULL.
authorRob Norris <rw_norris@hotmail.com>
Sun, 20 Jul 2014 09:27:24 +0000 (10:27 +0100)
committerRob Norris <rw_norris@hotmail.com>
Sun, 20 Jul 2014 09:54:14 +0000 (10:54 +0100)
I haven't been able to trace why/when tmp becomes NULL,
 but at least one user has encountered this condition.
Thus add protection against deferencing a NULL pointer.

src/mapcache.c

index 5417ae1a2feaaf6aedb4ca847876141f7b21d5be..16422abebe0d4ff5aeae3c95bdf3a4fd98cc1c82 100644 (file)
@@ -182,6 +182,7 @@ void a_mapcache_remove_all_shrinkfactors ( gint x, gint y, gint z, guint16 type,
   /* TODO: check logic here */
   do {
     tmp = loop->next;
+    if ( tmp ) {
     if ( strncmp(tmp->key, key, len) == 0 )
     {
       cache_remove(tmp->key);
@@ -198,7 +199,8 @@ void a_mapcache_remove_all_shrinkfactors ( gint x, gint y, gint z, guint16 type,
     }
     else
       loop = tmp;
-
+    } else
+      loop = NULL;
   } while ( loop && (loop != queue_tail || tmp == NULL) );
 
   /* loop thru list, looking for the one, compare first whatever chars */