From: kgv Date: Fri, 27 May 2016 13:00:05 +0000 (+0300) Subject: 0027522: Foundation Classes, FSD_BinaryFile - incorrect size check in a stream X-Git-Tag: V7_0_winwerth~30 X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=402cfabc219dd4ccb25c10669114b840c7305524;p=occt-copy.git 0027522: Foundation Classes, FSD_BinaryFile - incorrect size check in a stream FSD_BinaryFile::ReadExtendedString() now compares read bytes, not symbols. --- diff --git a/src/FSD/FSD_BinaryFile.cxx b/src/FSD/FSD_BinaryFile.cxx index 0a40d2d2c7..3f344161e2 100644 --- a/src/FSD/FSD_BinaryFile.cxx +++ b/src/FSD/FSD_BinaryFile.cxx @@ -1639,13 +1639,13 @@ void FSD_BinaryFile::ReadExtendedString (Standard_IStream& theIStream, TCollecti Storage_StreamReadError::Raise(); } - theIStream.read ((char *)c, size*sizeof(Standard_ExtCharacter)); - - if (theIStream.gcount() != size) + const std::streamsize aNbBytes = std::streamsize(sizeof(Standard_ExtCharacter) * size); + theIStream.read ((char *)c, aNbBytes); + if (theIStream.gcount() != aNbBytes) { Storage_StreamReadError::Raise(); } - + c[size] = '\0'; #if OCCT_BINARY_FILE_DO_INVERSE