]> git.street.me.uk Git - andy/viking.git/commitdiff
Prevent crashing when queue_tail is NULL.
authorRob Norris <rw_norris@hotmail.com>
Mon, 30 Jun 2014 18:26:05 +0000 (19:26 +0100)
committerRob Norris <rw_norris@hotmail.com>
Sun, 13 Jul 2014 11:54:33 +0000 (12:54 +0100)
This can be induced if the map cache size is very low (e.g. 1Mb),
 such that the queue has no values.

src/mapcache.c

index 200806530758aafe953d52a3a653604574710d97..7e5638230cb223c00e5ff5bfb74725aa4399d96c 100644 (file)
@@ -137,15 +137,16 @@ void a_mapcache_add ( GdkPixbuf *pixbuf, gint x, gint y, gint z, guint16 type, g
   max_queue_size = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "mapcache_size")->u * 1024 * 1024;
 
   if ( queue_size > max_queue_size ) {
-    gchar *oldkey = list_shift_add_entry ( key );
-    cache_remove(oldkey);
-
-    while ( queue_size > max_queue_size &&
-        (queue_tail->next != queue_tail) ) { /* make sure there's more than one thing to delete */
-      oldkey = list_shift ();
+    if ( queue_tail ) {
+      gchar *oldkey = list_shift_add_entry ( key );
       cache_remove(oldkey);
-    }
 
+      while ( queue_size > max_queue_size &&
+             (queue_tail->next != queue_tail) ) { /* make sure there's more than one thing to delete */
+        oldkey = list_shift ();
+        cache_remove(oldkey);
+      }
+    }
     /* chop off 'start' etc */
   } else {
     list_add_entry ( key );