]> OCCT Git - occt-copy.git/commitdiff
0027522: Foundation Classes, FSD_BinaryFile - incorrect size check in a stream
authorkgv <kgv@opencascade.com>
Fri, 27 May 2016 13:00:05 +0000 (16:00 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 2 Jun 2016 11:23:17 +0000 (14:23 +0300)
FSD_BinaryFile::ReadExtendedString() now compares read bytes, not symbols.

src/FSD/FSD_BinaryFile.cxx

index 0a40d2d2c7047c5c1187765d3415072b031f3759..3f344161e245f210ddf9cad39c218102087a3341 100644 (file)
@@ -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