Kaydet (Commit) 838ad7a9 authored tarafından Caolán McNamara's avatar Caolán McNamara Kaydeden (comit) Andras Timar

check for stream status after a read, not after a seek

Change-Id: I984e99c1a1484547aa4d60bf301167f3cbc9f716
(cherry picked from commit eea399dd)
Reviewed-on: https://gerrit.libreoffice.org/18088Reviewed-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
Tested-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
üst c004f80a
...@@ -319,7 +319,7 @@ bool Section::GetDictionary( Dictionary& rDict ) ...@@ -319,7 +319,7 @@ bool Section::GetDictionary( Dictionary& rDict )
void Section::Read( SotStorageStream *pStrm ) void Section::Read( SotStorageStream *pStrm )
{ {
sal_uInt32 i, nSecOfs, nPropType, nPropSize, nCurrent, nVectorCount, nTemp, nStrmSize; sal_uInt32 i, nSecOfs, nPropSize, nStrmSize;
nSecOfs = pStrm->Tell(); nSecOfs = pStrm->Tell();
pStrm->Seek( STREAM_SEEK_TO_END ); pStrm->Seek( STREAM_SEEK_TO_END );
...@@ -329,16 +329,20 @@ void Section::Read( SotStorageStream *pStrm ) ...@@ -329,16 +329,20 @@ void Section::Read( SotStorageStream *pStrm )
mnTextEnc = RTL_TEXTENCODING_MS_1252; mnTextEnc = RTL_TEXTENCODING_MS_1252;
sal_uInt32 nSecSize(0), nPropCount(0); sal_uInt32 nSecSize(0), nPropCount(0);
pStrm->ReadUInt32( nSecSize ).ReadUInt32( nPropCount ); pStrm->ReadUInt32( nSecSize ).ReadUInt32( nPropCount );
while (nPropCount-- && pStrm->good()) while (nPropCount--)
{ {
sal_uInt32 nPropId(0), nPropOfs(0); sal_uInt32 nPropId(0), nPropOfs(0);
pStrm->ReadUInt32( nPropId ).ReadUInt32( nPropOfs ); pStrm->ReadUInt32(nPropId).ReadUInt32(nPropOfs);
nCurrent = pStrm->Tell(); if (!pStrm->good())
pStrm->Seek( nPropOfs + nSecOfs ); break;
auto nCurrent = pStrm->Tell();
sal_uInt64 nOffset = nPropOfs + nSecOfs;
if (nOffset != pStrm->Seek(nOffset))
break;
if ( nPropId ) // do not read dictionary if ( nPropId ) // do not read dictionary
{ {
sal_uInt32 nPropType(0), nVectorCount(0);
pStrm->ReadUInt32( nPropType ); pStrm->ReadUInt32(nPropType);
nPropSize = 4; nPropSize = 4;
...@@ -360,6 +364,7 @@ void Section::Read( SotStorageStream *pStrm ) ...@@ -360,6 +364,7 @@ void Section::Read( SotStorageStream *pStrm )
pStrm->ReadUInt32( nPropType ); pStrm->ReadUInt32( nPropType );
nPropSize += 4; nPropSize += 4;
} }
sal_uInt32 nTemp(0);
switch( nPropType ) switch( nPropType )
{ {
case VT_UI1 : case VT_UI1 :
...@@ -457,11 +462,11 @@ void Section::Read( SotStorageStream *pStrm ) ...@@ -457,11 +462,11 @@ void Section::Read( SotStorageStream *pStrm )
PropItem aPropItem; PropItem aPropItem;
if ( GetProperty( 1, aPropItem ) ) if ( GetProperty( 1, aPropItem ) )
{ {
sal_uInt16 nCodePage;
aPropItem.ReadUInt32( nPropType ); aPropItem.ReadUInt32( nPropType );
if ( nPropType == VT_I2 ) if ( nPropType == VT_I2 )
{ {
aPropItem.ReadUInt16( nCodePage ); sal_uInt16 nCodePage(0);
aPropItem.ReadUInt16(nCodePage);
if ( nCodePage == 1200 ) if ( nCodePage == 1200 )
{ {
...@@ -503,7 +508,7 @@ void Section::Read( SotStorageStream *pStrm ) ...@@ -503,7 +508,7 @@ void Section::Read( SotStorageStream *pStrm )
AddProperty( 0xffffffff, pBuf, nSize ); AddProperty( 0xffffffff, pBuf, nSize );
delete[] pBuf; delete[] pBuf;
} }
pStrm->Seek( nCurrent ); pStrm->Seek(nCurrent);
} }
pStrm->Seek( nSecOfs + nSecSize ); pStrm->Seek( nSecOfs + nSecSize );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment