[Libreoffice-commits] .: binfilter/bf_svtools
Caolán McNamara
caolan at kemper.freedesktop.org
Mon Apr 4 06:30:58 PDT 2011
binfilter/bf_svtools/source/filerec/svt_filerec.cxx | 12 ++++--
binfilter/bf_svtools/source/inc/poolio.hxx | 10 +++++
binfilter/bf_svtools/source/items1/svt_poolio.cxx | 40 ++++++++++----------
3 files changed, 39 insertions(+), 23 deletions(-)
New commits:
commit db644321a5010ceb75696e5a15d1b7533b1b9e91
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon Apr 4 14:27:30 2011 +0100
handle incomplete reads more gracefully
diff --git a/binfilter/bf_svtools/source/filerec/svt_filerec.cxx b/binfilter/bf_svtools/source/filerec/svt_filerec.cxx
index 4157bb3..79e8b36 100644
--- a/binfilter/bf_svtools/source/filerec/svt_filerec.cxx
+++ b/binfilter/bf_svtools/source/filerec/svt_filerec.cxx
@@ -656,12 +656,13 @@ bool SfxMultiRecordReader::ReadHeader_Impl()
else
_pStream->Seek( _nContentSize );
_pContentOfs = new UINT32[_nContentCount];
+ memset(_pContentOfs, 0, _nContentCount*sizeof(UINT32));
//! darf man jetzt so einr"ucken
#if defined(OSL_LITENDIAN)
- _pStream->Read( _pContentOfs, sizeof(UINT32)*_nContentCount );
+ _pStream->Read( _pContentOfs, sizeof(UINT32)*_nContentCount );
#else
- for ( USHORT n = 0; n < _nContentCount; ++n )
- *_pStream >> _pContentOfs[n];
+ for ( USHORT n = 0; n < _nContentCount; ++n )
+ *_pStream >> _pContentOfs[n];
#endif
_pStream->Seek( nContentPos );
}
@@ -673,7 +674,10 @@ bool SfxMultiRecordReader::ReadHeader_Impl()
//-------------------------------------------------------------------------
SfxMultiRecordReader::SfxMultiRecordReader( SvStream *pStream, UINT16 nTag )
-: _nContentNo(0)
+ : _pContentOfs(0)
+ , _nContentSize(0)
+ , _nContentCount(0)
+ , _nContentNo(0)
{
// Position im Stream merken, um im Fehlerfall zur"uck-seeken zu k"onnen
_nStartPos = pStream->Tell();
diff --git a/binfilter/bf_svtools/source/inc/poolio.hxx b/binfilter/bf_svtools/source/inc/poolio.hxx
index 8e9fa66..437c575 100644
--- a/binfilter/bf_svtools/source/inc/poolio.hxx
+++ b/binfilter/bf_svtools/source/inc/poolio.hxx
@@ -89,6 +89,16 @@ struct SfxItemPool_Impl
SfxItemPool_Impl( USHORT nStart, USHORT nEnd )
: ppPoolItems (new SfxPoolItemArray_Impl*[ nEnd - nStart + 1])
+ , nLoadingVersion(0)
+ , nInitRefCount(0)
+ , nVerStart(0)
+ , nVerEnd(0)
+ , nStoringStart(0)
+ , nStoringEnd(0)
+ , nMajorVer(0)
+ , nMinorVer(0)
+ , bInSetItem(false)
+ , bStreaming(false)
{
memset( ppPoolItems, 0, sizeof( SfxPoolItemArray_Impl* ) * ( nEnd - nStart + 1) );
}
diff --git a/binfilter/bf_svtools/source/items1/svt_poolio.cxx b/binfilter/bf_svtools/source/items1/svt_poolio.cxx
index f7910b8..f5aa934 100644
--- a/binfilter/bf_svtools/source/items1/svt_poolio.cxx
+++ b/binfilter/bf_svtools/source/items1/svt_poolio.cxx
@@ -405,7 +405,7 @@ void SfxItemPool::readTheItems (
nLastSurrogate = nSurrogate;
// Ref-Count und Item laden
- USHORT nRef;
+ USHORT nRef(0);
rStream >> nRef;
pItem = pDefItem->Create(rStream, nVersion);
@@ -608,7 +608,7 @@ SvStream &SfxItemPool::Load(SvStream &rStream)
for ( USHORT nVerNo = 0; aVerRec.GetContent(); ++nVerNo )
{
// Header f"ur einzelne Version einlesen
- USHORT nVersion, nHStart, nHEnd;
+ USHORT nVersion(0), nHStart(0), nHEnd(0);
rStream >> nVersion >> nHStart >> nHEnd;
USHORT nCount = nHEnd - nHStart + 1;
@@ -617,6 +617,7 @@ SvStream &SfxItemPool::Load(SvStream &rStream)
{
// neue Version hinzufuegen
USHORT *pMap = new USHORT[nCount];
+ memset(pMap, 0, nCount * sizeof(USHORT));
for ( USHORT n = 0; n < nCount; ++n )
rStream >> pMap[n];
SetVersionMap( nVersion, nHStart, nHEnd, pMap );
@@ -633,7 +634,7 @@ SvStream &SfxItemPool::Load(SvStream &rStream)
while ( aWhichIdsRec.GetContent() )
{
// SlotId, Which-Id und Item-Version besorgen
- USHORT nCount, nVersion, nWhich;
+ USHORT nCount(0), nVersion(0), nWhich(0);
rStream >> nWhich;
if ( pImp->nLoadingVersion != pImp->nVersion )
// Which-Id aus File-Version in Pool-Version verschieben
@@ -681,7 +682,7 @@ SvStream &SfxItemPool::Load(SvStream &rStream)
while ( aDefsRec.GetContent() )
{
// SlotId, Which-Id und Item-Version besorgen
- USHORT nVersion, nWhich;
+ USHORT nVersion(0), nWhich(0);
rStream >> nWhich;
if ( pImp->nLoadingVersion != pImp->nVersion )
// Which-Id aus File-Version in Pool-Version verschieben
@@ -731,7 +732,7 @@ SvStream &SfxItemPool::Load1_Impl(SvStream &rStream)
CHECK_FILEFORMAT( rStream, SFX_ITEMPOOL_TAG_STARTPOOL_4 );
rStream >> pImp->nMajorVer >> pImp->nMinorVer;
}
- sal_uInt32 nAttribSize;
+ sal_uInt32 nAttribSize(0);
int bOwnPool = TRUE;
UniString aExternName;
if ( pImp->nMajorVer > 1 || pImp->nMinorVer >= 2 )
@@ -764,7 +765,7 @@ SvStream &SfxItemPool::Load1_Impl(SvStream &rStream)
ULONG nStartPos = rStream.Tell();
rStream.SeekRel( nAttribSize );
CHECK_FILEFORMAT( rStream, SFX_ITEMPOOL_TAG_SIZES );
- sal_uInt32 nSizeTableLen;
+ sal_uInt32 nSizeTableLen(0);
rStream >> nSizeTableLen;
sal_Char *pBuf = new sal_Char[nSizeTableLen];
rStream.Read( pBuf, nSizeTableLen );
@@ -776,18 +777,18 @@ SvStream &SfxItemPool::Load1_Impl(SvStream &rStream)
{
// Version-Map finden (letztes ULONG der Size-Table gibt Pos an)
rStream.Seek( nEndOfSizes - sizeof(sal_uInt32) );
- sal_uInt32 nVersionMapPos;
+ sal_uInt32 nVersionMapPos(0);
rStream >> nVersionMapPos;
rStream.Seek( nVersionMapPos );
// Versions-Maps einlesen
CHECK_FILEFORMAT( rStream, SFX_ITEMPOOL_TAG_VERSIONMAP );
- USHORT nVerCount;
+ USHORT nVerCount(0);
rStream >> nVerCount;
for ( USHORT nVerNo = 0; nVerNo < nVerCount; ++nVerNo )
{
// Header f"ur einzelne Version einlesen
- USHORT nVersion, nHStart, nHEnd;
+ USHORT nVersion(0), nHStart(0), nHEnd(0);
rStream >> nVersion >> nHStart >> nHEnd;
USHORT nCount = nHEnd - nHStart + 1;
USHORT nBytes = (nCount)*sizeof(USHORT);
@@ -797,6 +798,7 @@ SvStream &SfxItemPool::Load1_Impl(SvStream &rStream)
{
// neue Version hinzufuegen
USHORT *pMap = new USHORT[nCount];
+ memset(pMap, 0, nCount * sizeof(USHORT));
for ( USHORT n = 0; n < nCount; ++n )
rStream >> pMap[n];
SetVersionMap( nVersion, nHStart, nHEnd, pMap );
@@ -812,7 +814,7 @@ SvStream &SfxItemPool::Load1_Impl(SvStream &rStream)
CHECK_FILEFORMAT( rStream, SFX_ITEMPOOL_TAG_ITEMS );
bool bSecondaryLoaded = FALSE;
long nSecondaryEnd = 0;
- USHORT nWhich, nSlot;
+ USHORT nWhich(0), nSlot(0);
while ( rStream >> nWhich, nWhich )
{
// ggf. Which-Id aus alter Version verschieben?
@@ -823,8 +825,8 @@ SvStream &SfxItemPool::Load1_Impl(SvStream &rStream)
USHORT nMappedWhich = GetWhich(nSlot, FALSE);
int bKnownItem = bOwnPool || IsWhich(nMappedWhich);
- USHORT nRef, nCount, nVersion;
- sal_uInt32 nAttrSize;
+ USHORT nRef(0), nCount(0), nVersion(0);
+ sal_uInt32 nAttrSize(0);
rStream >> nVersion >> nCount;
SfxPoolItemArray_Impl **ppArr = 0;
@@ -968,8 +970,8 @@ SvStream &SfxItemPool::Load1_Impl(SvStream &rStream)
int bKnownItem = bOwnPool || IsWhich(nMappedWhich);
ULONG nPos = nLastPos;
- sal_uInt32 nSize;
- USHORT nVersion;
+ sal_uInt32 nSize(0);
+ USHORT nVersion(0);
rStream >> nVersion;
if ( bKnownItem )
@@ -1059,7 +1061,7 @@ const SfxPoolItem* SfxItemPool::LoadSurrogate
{
// erstmal das Surrogat lesen
- USHORT nSurrogat;
+ USHORT nSurrogat(0);
rStream >> nSurrogat;
// direkt gespeichertes Item?
@@ -1573,7 +1575,7 @@ const SfxPoolItem* SfxItemPool::LoadItem( SvStream &rStream, bool bDirect,
// pRefPool==-1 => nicht putten!
{
- USHORT nWhich, nSlot; // nSurrogate;
+ USHORT nWhich=0, nSlot=0; // nSurrogate;
rStream >> nWhich >> nSlot;
BOOL bDontPut = (SfxItemPool*)-1 == pRefPool;
@@ -1588,7 +1590,7 @@ const SfxPoolItem* SfxItemPool::LoadItem( SvStream &rStream, bool bDirect,
else
{
// WID in der Version nicht vorhanden => ueberspringen
- USHORT nSurro, nVersion, nLen;
+ USHORT nSurro(0), nVersion(0), nLen(0);
rStream >> nSurro;
if ( SFX_ITEMS_DIRECT == nSurro )
{
@@ -1626,8 +1628,8 @@ const SfxPoolItem* SfxItemPool::LoadItem( SvStream &rStream, bool bDirect,
if ( bDirect || ( nWhich && !pItem ) )
{
// bDirekt bzw. nicht IsPoolable() => Item direkt laden
- USHORT nVersion;
- sal_uInt32 nLen;
+ USHORT nVersion(0);
+ sal_uInt32 nLen(0);
rStream >> nVersion >> nLen;
ULONG nIStart = rStream.Tell();
More information about the Libreoffice-commits
mailing list