diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2006-01-24 13:48:43 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2006-01-24 13:48:43 +0000 |
commit | c0f7e19ead3520f07c50616e84d483c966a0c5b9 (patch) | |
tree | 4640c131f3d0f1452963bbac436a76c1034083e9 /sot | |
parent | e241121a3cb23f453ef928cee37fce87a8319916 (diff) |
INTEGRATION: CWS impress82 (1.6.20); FILE MERGED
2006/01/13 16:51:42 sj 1.6.20.1: #121813# not reading uninitialized memory
Diffstat (limited to 'sot')
-rw-r--r-- | sot/source/sdstor/stgcache.cxx | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/sot/source/sdstor/stgcache.cxx b/sot/source/sdstor/stgcache.cxx index 89f861a57c9a..caea50e6ceb1 100644 --- a/sot/source/sdstor/stgcache.cxx +++ b/sot/source/sdstor/stgcache.cxx @@ -4,9 +4,9 @@ * * $RCSfile: stgcache.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: rt $ $Date: 2005-09-08 07:40:35 $ + * last change: $Author: hr $ $Date: 2006-01-24 14:48:43 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -427,21 +427,33 @@ BOOL StgCache::Read( INT32 nPage, void* pBuf, INT32 nPg ) { if( Good() ) { - ULONG nPos = Page2Pos( nPage ); - ULONG nBytes = nPg * nPageSize; - // fixed address and size for the header - if( nPage == -1 ) - nPos = 0L, nBytes = 512; - if( pStrm->Tell() != nPos ) + if ( nPage >= nPages ) + SetError( SVSTREAM_READ_ERROR ); + else { - ULONG nPhysPos = pStrm->Seek( nPos ); -#ifdef CHECK_DIRTY - if( nPhysPos != nPos ) - ErrorBox( NULL, WB_OK, String("SO2: Seek failed") ).Execute(); -#endif + ULONG nPos = Page2Pos( nPage ); + INT32 nPg2 = ( ( nPage + nPg ) > nPages ) ? nPages - nPage : nPg; + ULONG nBytes = nPg2 * nPageSize; + // fixed address and size for the header + if( nPage == -1 ) + { + nPos = 0L, nBytes = 512; + nPg2 = nPg; + } + if( pStrm->Tell() != nPos ) + { + ULONG nPhysPos = pStrm->Seek( nPos ); + #ifdef CHECK_DIRTY + if( nPhysPos != nPos ) + ErrorBox( NULL, WB_OK, String("SO2: Seek failed") ).Execute(); + #endif + } + pStrm->Read( pBuf, nBytes ); + if ( nPg != nPg2 ) + SetError( SVSTREAM_READ_ERROR ); + else + SetError( pStrm->GetError() ); } - pStrm->Read( pBuf, nBytes ); - SetError( pStrm->GetError() ); } return Good(); } |