On Fri, Aug 14, 2009 at 2:59 AM, Srikanth<[email protected]> wrote: > Dear All, > > I am reading and writing raster images using GDAL. Below is the code which I > am using for writing a raster. > At times the code is working fine. But many a time , it is getting crashed > in the GetRasterBand. I have debugged the code several times and the > variables passed seems to be perfect. Any help in this is regard would be > appreciated. ... > poDataset=NULL; > poDataset = poDriver->Create(filename , width , height , numOfbands > ,(GDALDataType)datatype,NULL); > > for(int i=0 ; i < numOfbands ; i++) > { > poBand[i] = poDataset->GetRasterBand(i+1); > }
Hi, I didn't see any showstopper problems in your code. But the above code is not safe if the dataset creation fails. If the dataset creation fails, a null pointer will be returned and GetRasterBand() will fail - possibly crashing. Best regards, -- ---------------------------------------+-------------------------------------- I set the clouds in motion - turn up | Frank Warmerdam, [email protected] light and sound - activate the windows | http://pobox.com/~warmerdam and watch the world go round - Rush | Geospatial Programmer for Rent _______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
