diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.cpp index 213946dd57228f2c615f15e13558361ec3c60c6f..7133a856fd0f68458191f3e2492d6b0828cad63e 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.cpp @@ -1025,7 +1025,17 @@ namespace ossimplugins // Find first valid samples if(*sIt!="-1") { - int Fvs = atoi((*sIt).c_str()); + int Fvs = samplesPerBurst; + try + { + Fvs = std::stoi(*sIt); + } + catch( ... ) + { + // Throw an execption + throw std::runtime_error("Failed to convert firstValidSample value."); + } + if (Fvs > first_sample_valid && Fvs < samplesPerBurst) { first_sample_valid = Fvs; @@ -1043,7 +1053,16 @@ namespace ossimplugins // Last first valid samples if(*sIt!="-1") { - int Lvs = atoi((*sIt).c_str()); + int Lvs = 0; + try + { + Lvs = std::stoi(*sIt); + } + catch( ... ) + { + // Throw an execption + throw std::runtime_error("Failed to convert lastValidSample value."); + } if (Lvs < last_sample_valid && Lvs > 0) { last_sample_valid = Lvs; diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1SarSensorModel.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1SarSensorModel.cpp index fbc7ee22e33b714e305e8455a02509fbbbdf573c..7f6cb886f78b9ac021cc0ff2c6b79f4b9b07995a 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1SarSensorModel.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1SarSensorModel.cpp @@ -237,7 +237,16 @@ void ossimSentinel1SarSensorModel::readAnnotationFile(const std::string & annota // Find first valid samples if(*sIt!="-1") { - int Fvs = atoi((*sIt).c_str()); + int Fvs = samplesPerBurst; + try + { + Fvs = std::stoi(*sIt); + } + catch( ... ) + { + // Throw an execption + throw std::runtime_error("Failed to convert firstValidSample value."); + } if (Fvs > first_sample_valid && Fvs < samplesPerBurst) { first_sample_valid = Fvs; @@ -255,7 +264,17 @@ void ossimSentinel1SarSensorModel::readAnnotationFile(const std::string & annota // Last first valid samples if(*sIt!="-1") { - int Lvs = atoi((*sIt).c_str()); + int Lvs = 0; + try + { + Lvs = std::stoi(*sIt); + } + catch( ... ) + { + // Throw an execption + throw std::runtime_error("Failed to convert lastValidSample value."); + } + if (Lvs < last_sample_valid && Lvs > 0) { last_sample_valid = Lvs;