diff --git a/Testing/Code/IO/otbGDALImageIOTestWriteMetadata.cxx b/Testing/Code/IO/otbGDALImageIOTestWriteMetadata.cxx index ea35313d6733bc2f2d715627c7d47ce6ac17b283..3cd06304e4a5471b6ed81bdee953cbcd25d52f4c 100644 --- a/Testing/Code/IO/otbGDALImageIOTestWriteMetadata.cxx +++ b/Testing/Code/IO/otbGDALImageIOTestWriteMetadata.cxx @@ -502,7 +502,8 @@ bool writeReadDatasetMetadata(std::string filename, std::vector<std::string> opt strIndexGCP << 1; std::string sstrIndexGCP = strIndexGCP.str(); - gdalGcps[0].pszId = const_cast<char *>(sstrIndexGCP.c_str()); + gdalGcps[0].pszId = new char[sstrIndexGCP.length()+1]; + std::strcpy(gdalGcps[0].pszId,sstrIndexGCP.c_str()); gdalGcps[0].pszInfo = const_cast<char *>("GCP test"); gdalGcps[0].dfGCPPixel = 0.5; gdalGcps[0].dfGCPLine = 0.5; @@ -512,6 +513,7 @@ bool writeReadDatasetMetadata(std::string filename, std::vector<std::string> opt poDstDS->SetGCPs(gcpCount, gdalGcps, pszSRS_WKT_GCP); + delete [] gdalGcps[0].pszId; delete[] gdalGcps; /*infoDatasetCreate->m_GCPProjRef = static_cast<std::string>( pszSRS_WKT);