[Gdal-dev] Problems with writing RasterIO on WinXP

Frank Warmerdam warmerdam at pobox.com
Wed Jun 2 16:37:12 EDT 2004


> float *analyseBuffer(float *hrBuffer, float *lrBuffer, int bsize) {
>     float *fuBuffer;
>     fuBuffer = (float *) CPLMalloc(sizeof(float)*bsize);
>     int i=1;
>     while (i <= bsize) {
>         fuBuffer[i]=(hrBuffer[i] + hrBuffer[i] + lrBuffer[i]) / 3;
>         i += 1;
>     };    
>     return fuBuffer;
> }

Jochen,

I noticed a couple of things.  Your loop above should be from i=0 to bsize-1
but you are looping from 1 to bsize which will write one word past the end
of the buffer potentially corrupting the heap.  Heap corruption has
unpredictable effects.  It might not break anything on one run, and crap out
on another run.

The other thing is that you aren't closing the files.  You should explicitly
"delete fusionDataset" at the end to get things flushed and closed properly.

Ahh heap corruption, the C/C++ programmers eternal pain.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent




More information about the Gdal-dev mailing list