sw/source/filter/ww8/ww8scan.cxx | 57 ++++++++------------------------------- sw/source/filter/ww8/ww8scan.hxx | 5 +-- 2 files changed, 15 insertions(+), 47 deletions(-)
New commits: commit 4466a7949af63621a2b180715de2ae3675343715 Author: Caolán McNamara <caol...@redhat.com> Date: Fri Aug 14 15:45:18 2015 +0100 convert pPieceGrpprls to vector and merge calc and load loops together we retain the max-short limit but no longer add a null terminating entry Change-Id: Ie195e0c244cc08643a9c22518c85d70a883752b7 diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index ad1ef67..a34dc30 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -936,8 +936,8 @@ const sal_uInt8* WW8SprmIter::FindSprm(sal_uInt16 nId) WW8PLCFx_PCDAttrs::WW8PLCFx_PCDAttrs(ww::WordVersion eVersion, WW8PLCFx_PCD* pPLCFx_PCD, const WW8ScannerBase* pBase) : WW8PLCFx(eVersion, true), pPcdI(pPLCFx_PCD->GetPLCFIter()), - pPcd(pPLCFx_PCD), pGrpprls(pBase->pPieceGrpprls), - nGrpprls(pBase->nPieceGrpprls) + pPcd(pPLCFx_PCD), pGrpprls(pBase->aPieceGrpprls.data()), + nGrpprls(pBase->aPieceGrpprls.size()) { } @@ -1504,43 +1504,14 @@ WW8PLCFpcd* WW8ScannerBase::OpenPieceTable( SvStream* pStr, const WW8Fib* pWwF ) return NULL; WW8_FC nClxPos = pWwF->fcClx; - sal_Int32 nClxLen = pWwF->lcbClx; - sal_Int32 nLeft = nClxLen; - sal_Int16 nGrpprl = 0; if (!checkSeek(*pStr, nClxPos)) return NULL; - while( true ) // count number of Grpprls - { - sal_uInt8 clxt(2); - pStr->ReadUChar( clxt ); - nLeft--; - if( 2 == clxt ) // PLCFfpcd ? - break; // PLCFfpcd found - if( 1 == clxt ) // clxtGrpprl ? - { - if (nGrpprl == SHRT_MAX) - return NULL; - nGrpprl++; - } - sal_uInt16 nLen(0); - pStr->ReadUInt16( nLen ); - nLeft -= 2 + nLen; - if( nLeft < 0 ) - return NULL; // gone wrong - pStr->SeekRel( nLen ); // ignore grpprl - } - - if (!checkSeek(*pStr, nClxPos)) - return NULL; + sal_Int32 nClxLen = pWwF->lcbClx; + sal_Int32 nLeft = nClxLen; - nLeft = nClxLen; - pPieceGrpprls = new sal_uInt8*[nGrpprl + 1]; - memset( pPieceGrpprls, 0, ( nGrpprl + 1 ) * sizeof(sal_uInt8 *) ); - nPieceGrpprls = nGrpprl; - sal_Int16 nAktGrpprl = 0; // read Grpprls - while( true ) + while (true) { sal_uInt8 clxt(2); pStr->ReadUChar( clxt ); @@ -1554,6 +1525,8 @@ WW8PLCFpcd* WW8ScannerBase::OpenPieceTable( SvStream* pStr, const WW8Fib* pWwF ) return NULL; // gone wrong if( 1 == clxt ) // clxtGrpprl ? { + if (aPieceGrpprls.size() == SHRT_MAX) + return NULL; if (nLen > pStr->remainingSize()) return NULL; sal_uInt8* p = new sal_uInt8[nLen+2]; // allocate @@ -1563,11 +1536,12 @@ WW8PLCFpcd* WW8ScannerBase::OpenPieceTable( SvStream* pStr, const WW8Fib* pWwF ) delete[] p; return NULL; } - pPieceGrpprls[nAktGrpprl++] = p; // add to array + aPieceGrpprls.push_back(p); // add to array } else - pStr->SeekRel( nLen ); // non-Grpprl left + pStr->SeekRel( nLen ); // non-Grpprl left } + // read Piece Table PLCF sal_Int32 nPLCFfLen(0); if (pWwF->GetFIBVersion() <= ww::eWW2) @@ -1584,20 +1558,15 @@ WW8PLCFpcd* WW8ScannerBase::OpenPieceTable( SvStream* pStr, const WW8Fib* pWwF ) void WW8ScannerBase::DeletePieceTable() { - if( pPieceGrpprls ) - { - for( sal_uInt8** p = pPieceGrpprls; *p; p++ ) - delete[] (*p); - delete[] pPieceGrpprls; - pPieceGrpprls = 0; - } + for (auto pGrppl : aPieceGrpprls) + delete[] pGrppl; } WW8ScannerBase::WW8ScannerBase( SvStream* pSt, SvStream* pTableSt, SvStream* pDataSt, WW8Fib* pWwFib ) : pWw8Fib(pWwFib), pMainFdoa(0), pHdFtFdoa(0), pMainTxbx(0), pMainTxbxBkd(0), pHdFtTxbx(0), pHdFtTxbxBkd(0), pMagicTables(0), - pSubdocs(0), pExtendedAtrds(0), pPieceGrpprls(0) + pSubdocs(0), pExtendedAtrds(0) { pPiecePLCF = OpenPieceTable( pTableSt, pWw8Fib ); // Complex if( pPiecePLCF ) diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx index 26a94ac..4be181b 100644 --- a/sw/source/filter/ww8/ww8scan.hxx +++ b/sw/source/filter/ww8/ww8scan.hxx @@ -412,7 +412,7 @@ class WW8PLCFx_PCDAttrs : public WW8PLCFx private: WW8PLCFpcd_Iter* pPcdI; WW8PLCFx_PCD* pPcd; - sal_uInt8** const pGrpprls; // attribute of Piece-table + sal_uInt8* const* pGrpprls; // attribute of Piece-table SVBT32 aShortSprm; // mini storage: can contain ONE sprm with // 1 byte param sal_uInt16 nGrpprls; // attribute count of this @@ -1011,8 +1011,7 @@ private: WW8PLCFpcd_Iter* pPieceIter; // for FastSave ( iterator for previous ) WW8PLCFx_PCD* pPLCFx_PCD; // ditto WW8PLCFx_PCDAttrs* pPLCFx_PCDAttrs; - sal_uInt8** pPieceGrpprls; // attributes of Piece-Table - sal_uInt16 nPieceGrpprls; // number of such attributes + std::vector<sal_uInt8*> aPieceGrpprls; // attributes of Piece-Table WW8PLCFpcd* OpenPieceTable( SvStream* pStr, const WW8Fib* pWwF ); void DeletePieceTable();
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits