Skip to content

Commit b762546

Browse files
committed
Fix crash on CONNECTIONTYPE kerneldensity on Windows (#5019)
1 parent 403f110 commit b762546

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

kerneldensity.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#ifdef USE_GDAL
3232

3333
#include "gdal.h"
34-
34+
#include "cpl_string.h"
3535

3636
void gaussian_blur(float *values, int width, int height, int radius) {
3737
float *tmp = (float*)msSmallMalloc(width*height*sizeof(float));
@@ -306,10 +306,13 @@ int msComputeKernelDensityDataset(mapObj *map, imageObj *image, layerObj *kernel
306306
free(values);
307307

308308
{
309+
char pointer[64];
309310
char ds_string [1024];
310311
double adfGeoTransform[6];
311-
snprintf(ds_string,1024,"MEM:::DATAPOINTER=%p,PIXELS=%u,LINES=%u,BANDS=1,DATATYPE=Byte,PIXELOFFSET=1,LINEOFFSET=%u",
312-
iValues,image->width,image->height,image->width);
312+
memset(pointer, 0, sizeof(pointer));
313+
CPLPrintPointer(pointer, iValues, sizeof(pointer));
314+
snprintf(ds_string,1024,"MEM:::DATAPOINTER=%s,PIXELS=%u,LINES=%u,BANDS=1,DATATYPE=Byte,PIXELOFFSET=1,LINEOFFSET=%u",
315+
pointer,image->width,image->height,image->width);
313316
hDS = GDALOpenShared( ds_string, GA_ReadOnly );
314317
if(hDS==NULL) {
315318
msSetError(MS_MISCERR,"msComputeKernelDensityDataset()","failed to create in-memory gdal dataset for interpolated data");

0 commit comments

Comments
 (0)