From 4e513a3346fb647f49fdbf9849328fcc8c691a54 Mon Sep 17 00:00:00 2001 From: Dimitrios Katsaros Date: Sun, 14 Aug 2016 22:17:55 +0200 Subject: [PATCH] Imgcodecs: Fixed a bug with checkSignature in GdalDecoder In cases where the signaure string contains a terminating character, the std::string member function size returns a smaller value than the allocated string. In these cases, if you then try to use substr, you will get an out_of_range exception. This patch remedies the problem. --- modules/imgcodecs/src/grfmt_gdal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/imgcodecs/src/grfmt_gdal.cpp b/modules/imgcodecs/src/grfmt_gdal.cpp index 1094b91b38..8865ae4948 100644 --- a/modules/imgcodecs/src/grfmt_gdal.cpp +++ b/modules/imgcodecs/src/grfmt_gdal.cpp @@ -559,7 +559,7 @@ bool GdalDecoder::checkSignature( const String& signature )const{ // look for NITF - std::string str = signature.c_str(); + std::string str(signature); if( str.substr(0,4).find("NITF") != std::string::npos ){ return true; }