Skip to content

Commit

Permalink
msSaveImageGDAL(): avoid false positive warning about nullptr deref (…
Browse files Browse the repository at this point in the history
…CID 1503386)
  • Loading branch information
rouault committed May 15, 2021
1 parent ce8c9d6 commit 99d55e1
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions mapgdal.c
Expand Up @@ -393,14 +393,12 @@ int msSaveImageGDAL( mapObj *map, imageObj *image, const char *filenameIn )
/* -------------------------------------------------------------------- */
/* Possibly assign a nodata value. */
/* -------------------------------------------------------------------- */
if( msGetOutputFormatOption(format,"NULLVALUE",NULL) != NULL ) {
int iBand;
const char *nullvalue = msGetOutputFormatOption(format,
"NULLVALUE",NULL);

for( iBand = 0; iBand < nBands; iBand++ ) {
const char *nullvalue = msGetOutputFormatOption(format,"NULLVALUE",NULL);
if( nullvalue != NULL ) {
const double dfNullValue = atof(nullvalue);
for( int iBand = 0; iBand < nBands; iBand++ ) {
GDALRasterBandH hBand = GDALGetRasterBand( hMemDS, iBand+1 );
GDALSetRasterNoDataValue( hBand, atof(nullvalue) );
GDALSetRasterNoDataValue( hBand, dfNullValue );
}
}

Expand Down

0 comments on commit 99d55e1

Please sign in to comment.