diff --git a/gdal/apps/gdal_contour.cpp b/gdal/apps/gdal_contour.cpp index 8624001ff14a..4d8970d8da3c 100644 --- a/gdal/apps/gdal_contour.cpp +++ b/gdal/apps/gdal_contour.cpp @@ -306,12 +306,7 @@ MAIN_START(argc, argv) /* -------------------------------------------------------------------- */ /* Try to get a coordinate system from the raster. */ /* -------------------------------------------------------------------- */ - OGRSpatialReferenceH hSRS = nullptr; - - const char *pszWKT = GDALGetProjectionRef( hSrcDS ); - - if( pszWKT != nullptr && strlen(pszWKT) != 0 ) - hSRS = OSRNewSpatialReference( pszWKT ); + OGRSpatialReferenceH hSRS = GDALGetSpatialRef( hSrcDS ); /* -------------------------------------------------------------------- */ /* Create the output file. */ @@ -471,14 +466,11 @@ MAIN_START(argc, argv) } CPLErr eErr = GDALContourGenerateEx( hBand, hLayer, options, pfnProgress, nullptr ); - + CSLDestroy( options ); OGR_DS_Destroy( hDS ); GDALClose( hSrcDS ); - if (hSRS) - OSRDestroySpatialReference( hSRS ); - CSLDestroy( argv ); CSLDestroy( papszDSCO ); CSLDestroy( papszLCO );