fix bug with invalid signature size (should not be less than signatureLength())

This commit is contained in:
Alexander Alekhin 2014-06-30 16:03:20 +04:00
parent 3a8af7d691
commit 5c8cd76893

View File

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