When getting a (hostile) dataset with huge block dimensions, a crash can occur
in gvrastercache.c if memory cannot be allocated
This patch replaces the g_new0 call that crashes with GLIB 1.2 by the standard
malloc.
Index: gvrastercache.c
===================================================================
RCS file: /cvsroot/openev/openev/gvrastercache.c,v
retrieving revision 1.12
diff -u -r1.12 gvrastercache.c
--- gvrastercache.c 20 Jun 2000 13:26:55 -0000 1.12
+++ gvrastercache.c 16 Nov 2007 19:58:12 -0000
@@ -32,6 +32,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include "gvrastercache.h"
static gint gv_cache_max = 20 * 1024 * 1024;
@@ -67,9 +68,10 @@
for( i = 0; i < cache->max_lod; i++ )
{
- cache->tiles[i] = g_new0(gv_raster_cache_tile*,cache->max_tiles);
+ cache->tiles[i] = malloc(sizeof(gv_raster_cache_tile*) *
cache->max_tiles);
if( cache->tiles[i] == NULL )
return NULL;
+ memset(cache->tiles[i], 0, sizeof(gv_raster_cache_tile*) *
cache->max_tiles);
}
return cache;
@@ -296,7 +298,7 @@
gv_raster_cache_flush_all( cache );
for( lod = 0; lod < cache->max_lod; lod++ )
- g_free( cache->tiles[lod] );
+ if (cache->tiles[lod]) free( cache->tiles[lod] );
g_free( cache->tiles );
|