]> git.street.me.uk Git - andy/viking.git/commitdiff
Add some safety checks and don't add the pixbuf into the cache if it's invalid.
authorRob Norris <rw_norris@hotmail.com>
Wed, 21 Aug 2013 22:31:43 +0000 (23:31 +0100)
committerRob Norris <rw_norris@hotmail.com>
Tue, 10 Sep 2013 22:09:34 +0000 (23:09 +0100)
src/vikmapslayer.c

index c54e28000f4d536ba0a0d31d783196bdd22b5d02..2de44c1c1b3d80f85dc93ff3a9ab1f2ea19c67e7 100644 (file)
@@ -667,6 +667,8 @@ static GdkPixbuf *pixbuf_set_alpha ( GdkPixbuf *pixbuf, guint8 alpha )
     GdkPixbuf *tmp = gdk_pixbuf_add_alpha(pixbuf,FALSE,0,0,0);
     g_object_unref(G_OBJECT(pixbuf));
     pixbuf = tmp;
+    if ( !pixbuf )
+      return NULL;
   }
 
   pixels = gdk_pixbuf_get_pixels(pixbuf);
@@ -729,9 +731,10 @@ static GdkPixbuf *get_pixbuf( VikMapsLayer *vml, gint mode, MapCoord *mapcoord,
           if ( xshrinkfactor != 1.0 || yshrinkfactor != 1.0 )
             pixbuf = pixbuf_shrink ( pixbuf, xshrinkfactor, yshrinkfactor );
 
-          a_mapcache_add ( pixbuf, mapcoord->x, mapcoord->y, 
-              mapcoord->z, vik_map_source_get_uniq_id(MAPS_LAYER_NTH_TYPE(vml->maptype)),
-              mapcoord->scale, vml->alpha, xshrinkfactor, yshrinkfactor );
+          if ( pixbuf )
+            a_mapcache_add ( pixbuf, mapcoord->x, mapcoord->y,
+                             mapcoord->z, vik_map_source_get_uniq_id(MAPS_LAYER_NTH_TYPE(vml->maptype)),
+                             mapcoord->scale, vml->alpha, xshrinkfactor, yshrinkfactor );
       }
     }
   }