[Libreoffice-commits] core.git: sw/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Thu Sep 2 09:07:33 UTC 2021
sw/source/filter/ww8/ww8graf2.cxx | 12 ++++++------
sw/source/filter/ww8/ww8par.hxx | 2 +-
sw/source/filter/ww8/ww8par3.cxx | 6 +++---
3 files changed, 10 insertions(+), 10 deletions(-)
New commits:
commit 0c5d9b14a8dd313247e1ed6890bb8b7a3a829b22
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Sep 1 09:11:45 2021 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Sep 2 11:06:57 2021 +0200
ofz: MemorySanitizer: use-of-uninitialized-value
Change-Id: Ic592091450d596d505b7e802cb8560be2c01cb0b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121451
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sw/source/filter/ww8/ww8graf2.cxx b/sw/source/filter/ww8/ww8graf2.cxx
index 2f40435c285d..de4ec0824686 100644
--- a/sw/source/filter/ww8/ww8graf2.cxx
+++ b/sw/source/filter/ww8/ww8graf2.cxx
@@ -440,7 +440,7 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf1(WW8_PIC const & rPic, SvStream* pSt,
return pRet;
}
-void SwWW8ImplReader::PicRead(SvStream *pDataStream, WW8_PIC *pPic,
+bool SwWW8ImplReader::PicRead(SvStream *pDataStream, WW8_PIC *pPic,
bool bVer67)
{
//Only the first 0x2e bytes are the same between version 6/7 and 8+
@@ -451,8 +451,10 @@ void SwWW8ImplReader::PicRead(SvStream *pDataStream, WW8_PIC *pPic,
pDataStream->ReadBytes(&i, bVer67 ? 2 : 4);
pDataStream->ReadInt16( pPic->dxaOrigin );
pDataStream->ReadInt16( pPic->dyaOrigin );
+ bool bOk = pDataStream->good();
if (!bVer67)
pDataStream->SeekRel(2); //cProps
+ return bOk;
}
namespace
@@ -491,14 +493,12 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj const * pTextObj,
*/
auto nOldPos = m_pDataStream->Tell();
WW8_PIC aPic;
- bool bValid = checkSeek(*m_pDataStream, m_nPicLocFc);
-
- if (bValid)
- PicRead( m_pDataStream, &aPic, m_bVer67);
+ bool bValid = checkSeek(*m_pDataStream, m_nPicLocFc) &&
+ PicRead(m_pDataStream, &aPic, m_bVer67);
// Sanity check is needed because for example check boxes in field results
// contain a WMF-like struct
- if (bValid && m_pDataStream->good() && (aPic.lcb >= 58))
+ if (bValid && aPic.lcb >= 58)
{
if( m_pFlyFormatOfJustInsertedGraphic )
{
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index 5122e772e3ea..ffab6636f377 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1897,7 +1897,7 @@ public: // really private, but can only be done public
const SwFormat* GetStyleWithOrgWWName( std::u16string_view rName ) const ;
static bool GetPictGrafFromStream(Graphic& rGraphic, SvStream& rSrc);
- static void PicRead( SvStream *pDataStream, WW8_PIC *pPic, bool bVer67);
+ SAL_WARN_UNUSED_RESULT static bool PicRead(SvStream *pDataStream, WW8_PIC *pPic, bool bVer67);
static bool ImportOleWMF(const tools::SvRef<SotStorage>& xSrc1, GDIMetaFile& rWMF, tools::Long& rX,
tools::Long& rY);
static Color GetCol(sal_uInt8 nIco);
diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index d8d061bd7a1a..64c2a2af20be 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -2102,10 +2102,10 @@ bool SwWW8ImplReader::ImportFormulaControl(WW8FormulaControl &aFormula,
sal_uLong nOldPos = m_pDataStream->Tell();
WW8_PIC aPic;
- m_pDataStream->Seek( nOffset);
- PicRead( m_pDataStream, &aPic, m_bVer67);
+ bool bValid = checkSeek(*m_pDataStream, nOffset) &&
+ PicRead(m_pDataStream, &aPic, m_bVer67);
- if((aPic.lcb > 0x3A) && !m_pDataStream->GetError() )
+ if (bValid && aPic.lcb > 0x3A)
{
aFormula.FormulaRead(nWhich,m_pDataStream);
bRet = true;
More information about the Libreoffice-commits
mailing list