diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-08-27 13:00:36 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2015-08-31 13:53:12 +0200 |
commit | 949aa59fccda3e10cd45e8f74984adde7b4fb161 (patch) | |
tree | 12826678cb5f65c4567e5fa8b06b4a074fc702ed /sd/source/filter | |
parent | 3a29fd1332434904d5421127bfd08ec135445302 (diff) |
check for stream status after a read, not after a seek
Change-Id: I984e99c1a1484547aa4d60bf301167f3cbc9f716
(cherry picked from commit eea399ddd52a0de368321963bb828bc15632dd0b)
Reviewed-on: https://gerrit.libreoffice.org/18075
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'sd/source/filter')
-rw-r--r-- | sd/source/filter/ppt/propread.cxx | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/sd/source/filter/ppt/propread.cxx b/sd/source/filter/ppt/propread.cxx index 1e71044c6a54..8f376fd71d8d 100644 --- a/sd/source/filter/ppt/propread.cxx +++ b/sd/source/filter/ppt/propread.cxx @@ -319,7 +319,7 @@ bool Section::GetDictionary( Dictionary& rDict ) void Section::Read( SvStorageStream *pStrm ) { - sal_uInt32 i, nSecOfs, nPropType, nPropSize, nCurrent, nVectorCount, nTemp, nStrmSize; + sal_uInt32 i, nSecOfs, nPropSize, nStrmSize; nSecOfs = pStrm->Tell(); pStrm->Seek( STREAM_SEEK_TO_END ); @@ -329,16 +329,20 @@ void Section::Read( SvStorageStream *pStrm ) mnTextEnc = RTL_TEXTENCODING_MS_1252; sal_uInt32 nSecSize(0), nPropCount(0); pStrm->ReadUInt32( nSecSize ).ReadUInt32( nPropCount ); - while (nPropCount-- && pStrm->good()) + while (nPropCount--) { sal_uInt32 nPropId(0), nPropOfs(0); - pStrm->ReadUInt32( nPropId ).ReadUInt32( nPropOfs ); - nCurrent = pStrm->Tell(); - pStrm->Seek( nPropOfs + nSecOfs ); + pStrm->ReadUInt32(nPropId).ReadUInt32(nPropOfs); + if (!pStrm->good()) + break; + auto nCurrent = pStrm->Tell(); + sal_uInt64 nOffset = nPropOfs + nSecOfs; + if (nOffset != pStrm->Seek(nOffset)) + break; if ( nPropId ) // do not read dictionary { - - pStrm->ReadUInt32( nPropType ); + sal_uInt32 nPropType(0), nVectorCount(0); + pStrm->ReadUInt32(nPropType); nPropSize = 4; @@ -360,6 +364,7 @@ void Section::Read( SvStorageStream *pStrm ) pStrm->ReadUInt32( nPropType ); nPropSize += 4; } + sal_uInt32 nTemp(0); switch( nPropType ) { case VT_UI1 : @@ -457,11 +462,11 @@ void Section::Read( SvStorageStream *pStrm ) PropItem aPropItem; if ( GetProperty( 1, aPropItem ) ) { - sal_uInt16 nCodePage; aPropItem.ReadUInt32( nPropType ); if ( nPropType == VT_I2 ) { - aPropItem.ReadUInt16( nCodePage ); + sal_uInt16 nCodePage(0); + aPropItem.ReadUInt16(nCodePage); if ( nCodePage == 1200 ) { @@ -503,7 +508,7 @@ void Section::Read( SvStorageStream *pStrm ) AddProperty( 0xffffffff, pBuf, nSize ); delete[] pBuf; } - pStrm->Seek( nCurrent ); + pStrm->Seek(nCurrent); } pStrm->Seek( nSecOfs + nSecSize ); } |