fix bug with invalid signature size (should not be less than signatureLength())
authorAlexander Alekhin <alexander.alekhin@itseez.com>
Mon, 30 Jun 2014 12:03:20 +0000 (16:03 +0400)
committerAlexander Alekhin <alexander.alekhin@itseez.com>
Mon, 30 Jun 2014 12:03:20 +0000 (16:03 +0400)
modules/highgui/src/loadsave.cpp

index 6658b13..81c708a 100644 (file)
@@ -137,9 +137,9 @@ static ImageDecoder findDecoder( const Mat& buf )
         maxlen = std::max(maxlen, len);
     }
 
+    string signature(maxlen, ' ');
     size_t bufSize = buf.rows*buf.cols*buf.elemSize();
     maxlen = std::min(maxlen, bufSize);
-    string signature(maxlen, ' ');
     memcpy( &signature[0], buf.data, maxlen );
 
     for( i = 0; i < codecs.decoders.size(); i++ )