[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.4' - 23 commits - lotuswordpro/source oox/source package/source registry/source reportdesign/source

Caolán McNamara caolanm at redhat.com
Thu Dec 10 04:01:14 PST 2015


 lotuswordpro/source/filter/lwp9reader.cxx          |    2 
 lotuswordpro/source/filter/lwpcelllayout.cxx       |    6 
 lotuswordpro/source/filter/lwpdoc.cxx              |   24 --
 lotuswordpro/source/filter/lwpfilter.cxx           |    2 
 lotuswordpro/source/filter/lwpfnlayout.cxx         |    4 
 lotuswordpro/source/filter/lwpfont.cxx             |    5 
 lotuswordpro/source/filter/lwpfootnote.cxx         |    2 
 lotuswordpro/source/filter/lwpfoundry.cxx          |   11 -
 lotuswordpro/source/filter/lwpframelayout.cxx      |    2 
 lotuswordpro/source/filter/lwpfrib.cxx             |    6 
 lotuswordpro/source/filter/lwpfribframe.cxx        |    2 
 lotuswordpro/source/filter/lwpfribptr.cxx          |    6 
 lotuswordpro/source/filter/lwpfribsection.cxx      |    6 
 lotuswordpro/source/filter/lwpfribtable.cxx        |    6 
 lotuswordpro/source/filter/lwpidxmgr.cxx           |    7 
 lotuswordpro/source/filter/lwplayout.cxx           |  219 +++++++++------------
 lotuswordpro/source/filter/lwplayout.hxx           |    5 
 lotuswordpro/source/filter/lwpnotes.cxx            |    6 
 lotuswordpro/source/filter/lwpobj.cxx              |    2 
 lotuswordpro/source/filter/lwpobj.hxx              |   15 +
 lotuswordpro/source/filter/lwpobjid.cxx            |    6 
 lotuswordpro/source/filter/lwpobjstrm.cxx          |    2 
 lotuswordpro/source/filter/lwppagelayout.cxx       |    7 
 lotuswordpro/source/filter/lwppara.cxx             |   40 ++-
 lotuswordpro/source/filter/lwppara1.cxx            |    2 
 lotuswordpro/source/filter/lwpsilverbullet.cxx     |    5 
 lotuswordpro/source/filter/lwpstory.cxx            |    3 
 lotuswordpro/source/filter/lwptablelayout.cxx      |    3 
 lotuswordpro/source/filter/lwptabrack.cxx          |    7 
 lotuswordpro/source/filter/lwptblformula.cxx       |    3 
 lotuswordpro/source/filter/lwptoc.cxx              |    6 
 lotuswordpro/source/filter/lwpvpointer.cxx         |    2 
 lotuswordpro/source/filter/xfilter/xfliststyle.cxx |    6 
 oox/source/export/chartexport.cxx                  |    2 
 package/source/zippackage/ZipPackage.cxx           |    6 
 registry/source/regimpl.cxx                        |    6 
 registry/source/registry.cxx                       |    8 
 reportdesign/source/core/sdr/RptObject.cxx         |    4 
 reportdesign/source/ui/dlg/Condition.cxx           |    3 
 reportdesign/source/ui/dlg/GroupsSorting.cxx       |    2 
 reportdesign/source/ui/report/ReportSection.cxx    |    3 
 41 files changed, 237 insertions(+), 227 deletions(-)

New commits:
commit 9b6ee9d77101c06798adeafdc7c1d8d608be28eb
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Dec 9 21:32:21 2015 +0000

    guard against infinite recursion on registering styles
    
    (cherry picked from commit 66686e443b568ad5aab1b32b3f25eb73487cfef6)
    Reviewed-on: https://gerrit.libreoffice.org/20554
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit 282b1aa32c27a513eb2858ad6e7e534ef52c1b99)
    
    Change-Id: Iabedfcce9d8ef21172e6bd0d654f3a258aae97e3
    Reviewed-on: https://gerrit.libreoffice.org/20555
    Reviewed-by: David Tardon <dtardon at redhat.com>
    Tested-by: David Tardon <dtardon at redhat.com>

diff --git a/lotuswordpro/source/filter/lwp9reader.cxx b/lotuswordpro/source/filter/lwp9reader.cxx
index b2a91ec..bba45304 100644
--- a/lotuswordpro/source/filter/lwp9reader.cxx
+++ b/lotuswordpro/source/filter/lwp9reader.cxx
@@ -192,7 +192,7 @@ void Lwp9Reader::ParseDocument()
 
     //Register Styles
     RegisteArrowStyles();
-    doc->RegisterStyle();
+    doc->DoRegisterStyle();
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
     pXFStyleManager->ToXml(m_pStream);
 
diff --git a/lotuswordpro/source/filter/lwpcelllayout.cxx b/lotuswordpro/source/filter/lwpcelllayout.cxx
index c5ac645..6b27d73 100644
--- a/lotuswordpro/source/filter/lwpcelllayout.cxx
+++ b/lotuswordpro/source/filter/lwpcelllayout.cxx
@@ -598,7 +598,7 @@ void LwpCellLayout::RegisterStyle()
     if (pObj.is())
     {
         pObj->SetFoundry(m_pFoundry);
-        pObj->RegisterStyle();
+        pObj->DoRegisterStyle();
     }
 
     //register child layout style
diff --git a/lotuswordpro/source/filter/lwpdoc.cxx b/lotuswordpro/source/filter/lwpdoc.cxx
index e3412fc..0a3597e 100644
--- a/lotuswordpro/source/filter/lwpdoc.cxx
+++ b/lotuswordpro/source/filter/lwpdoc.cxx
@@ -224,7 +224,7 @@ void LwpDocument::RegisterStyle()
     rtl::Reference<LwpObject> pDocSock = GetSocket().obj();
     if(pDocSock.is())
     {
-        pDocSock->RegisterStyle();
+        pDocSock->DoRegisterStyle();
     }
 }
 /**
@@ -322,7 +322,7 @@ void LwpDocument::RegisterGraphicsStyles()
     if(pGraphic.is())
     {
         pGraphic->SetFoundry(m_pFoundry);
-        pGraphic->RegisterStyle();
+        pGraphic->DoRegisterStyle();
     }
 }
 /**
@@ -619,7 +619,7 @@ LwpDocument* LwpDocument::GetPreviousDivision()
 
     LwpDocument* pDivision = GetFirstDivision();
 
-    while (pDivision)
+    while (pDivision && pDivision != this)
     {
         LwpDocument* pContentDivision = pDivision->GetFirstDivisionWithContentsThatIsNotOLE();
         if(pContentDivision)
@@ -782,11 +782,11 @@ void LwpDocSock::RegisterStyle()
 {
     rtl::Reference<LwpObject> pDoc = GetNext().obj();
     if(pDoc.is())
-        pDoc->RegisterStyle();
+        pDoc->DoRegisterStyle();
 
     pDoc = GetChildHead().obj();
     if(pDoc.is())
-        pDoc->RegisterStyle();
+        pDoc->DoRegisterStyle();
 }
  /**
  * @descr    parse contents of documents plugged
diff --git a/lotuswordpro/source/filter/lwpfnlayout.cxx b/lotuswordpro/source/filter/lwpfnlayout.cxx
index 86ddc5f..e02c597 100644
--- a/lotuswordpro/source/filter/lwpfnlayout.cxx
+++ b/lotuswordpro/source/filter/lwpfnlayout.cxx
@@ -164,7 +164,7 @@ void LwpFnCellLayout::RegisterStyle()
     if (pObj.is())
     {
         pObj->SetFoundry(m_pFoundry);
-        pObj->RegisterStyle();
+        pObj->DoRegisterStyle();
     }
 }
 
@@ -241,7 +241,7 @@ void LwpEnSuperTableLayout::RegisterStyle()
     if (pTableLayout != NULL)
     {
         pTableLayout->SetFoundry(m_pFoundry);
-        pTableLayout->RegisterStyle();
+        pTableLayout->DoRegisterStyle();
     }
 }
 
diff --git a/lotuswordpro/source/filter/lwpfootnote.cxx b/lotuswordpro/source/filter/lwpfootnote.cxx
index 5c64d00..86c69ff 100644
--- a/lotuswordpro/source/filter/lwpfootnote.cxx
+++ b/lotuswordpro/source/filter/lwpfootnote.cxx
@@ -181,7 +181,7 @@ void LwpFootnote::RegisterStyle()
         if(pContent)
         {
             pContent->SetFoundry(m_pFoundry);
-            pContent->RegisterStyle();
+            pContent->DoRegisterStyle();
         }
     }
 }
diff --git a/lotuswordpro/source/filter/lwpfoundry.cxx b/lotuswordpro/source/filter/lwpfoundry.cxx
index 232afb8..284fca2 100644
--- a/lotuswordpro/source/filter/lwpfoundry.cxx
+++ b/lotuswordpro/source/filter/lwpfoundry.cxx
@@ -202,7 +202,7 @@ void LwpFoundry::RegisterAllLayouts()
     if( pStyle.is() )
     {
         pStyle->SetFoundry(this);
-        pStyle->RegisterStyle();
+        pStyle->DoRegisterStyle();
     }
 
     //register content page layout list: Layout
@@ -210,7 +210,7 @@ void LwpFoundry::RegisterAllLayouts()
     if( pStyle.is() )
     {
         pStyle->SetFoundry(this);
-        pStyle->RegisterStyle();
+        pStyle->DoRegisterStyle();
     }
 
     //Register page style layout list: PageStyle, such as "Default Page"
@@ -218,7 +218,7 @@ void LwpFoundry::RegisterAllLayouts()
     if( pStyle.is() )
     {
         pStyle->SetFoundry(this);
-        pStyle->RegisterStyle();
+        pStyle->DoRegisterStyle();
     }
 
     //Register FrameStyle
@@ -226,7 +226,7 @@ void LwpFoundry::RegisterAllLayouts()
     if( pStyle.is() )
     {
         pStyle->SetFoundry(this);
-        pStyle->RegisterStyle();
+        pStyle->DoRegisterStyle();
     }
 
 }
diff --git a/lotuswordpro/source/filter/lwpframelayout.cxx b/lotuswordpro/source/filter/lwpframelayout.cxx
index 61325da..d902a04 100644
--- a/lotuswordpro/source/filter/lwpframelayout.cxx
+++ b/lotuswordpro/source/filter/lwpframelayout.cxx
@@ -867,7 +867,7 @@ void  LwpFrameLayout::RegisterStyle()
     if (content.is())
     {
         content->SetFoundry(m_pFoundry);
-        content->RegisterStyle();
+        content->DoRegisterStyle();
     }
 
     //register child frame style
diff --git a/lotuswordpro/source/filter/lwpfribframe.cxx b/lotuswordpro/source/filter/lwpfribframe.cxx
index fc16cfd..9f0161e 100644
--- a/lotuswordpro/source/filter/lwpfribframe.cxx
+++ b/lotuswordpro/source/filter/lwpfribframe.cxx
@@ -108,7 +108,7 @@ void LwpFribFrame::RegisterStyle(LwpFoundry* pFoundry)
         if (!pLayout)
             return;
         pLayout->SetFoundry(pFoundry);
-        pLayout->RegisterStyle();
+        pLayout->DoRegisterStyle();
 
         //register next frib text style
         sal_uInt8 nType = pLayout->GetRelativeType();
diff --git a/lotuswordpro/source/filter/lwplayout.cxx b/lotuswordpro/source/filter/lwplayout.cxx
index ee89168..3cff963 100644
--- a/lotuswordpro/source/filter/lwplayout.cxx
+++ b/lotuswordpro/source/filter/lwplayout.cxx
@@ -511,7 +511,7 @@ void LwpHeadLayout::RegisterStyle()
                 OSL_FAIL("Layout points to itself");
                 break;
             }
-            pLayout->RegisterStyle();
+            pLayout->DoRegisterStyle();
         }
         LwpVirtualLayout *pNext = dynamic_cast<LwpVirtualLayout*>(pLayout->GetNext().obj().get());
         if (pNext == pLayout)
diff --git a/lotuswordpro/source/filter/lwpnotes.cxx b/lotuswordpro/source/filter/lwpnotes.cxx
index c78fb4f..bec8487 100644
--- a/lotuswordpro/source/filter/lwpnotes.cxx
+++ b/lotuswordpro/source/filter/lwpnotes.cxx
@@ -92,7 +92,7 @@ void LwpFribNote::RegisterNewStyle()
         LwpFrib::RegisterStyle(m_pPara->GetFoundry());
         //register foonote style
         pLayout->SetFoundry(m_pPara->GetFoundry());
-        pLayout->RegisterStyle();
+        pLayout->DoRegisterStyle();
     }
 }
 
@@ -172,7 +172,7 @@ void LwpNoteLayout::RegisterStyle()
     if(pTextLayout)
     {
         pTextLayout->SetFoundry(GetFoundry());
-        pTextLayout->RegisterStyle();
+        pTextLayout->DoRegisterStyle();
     }
 }
 
@@ -284,7 +284,7 @@ void LwpNoteTextLayout::RegisterStyle()
     if(pContent.is())
     {
         pContent->SetFoundry(GetFoundry());
-        pContent->RegisterStyle();
+        pContent->DoRegisterStyle();
     }
 }
 
diff --git a/lotuswordpro/source/filter/lwpobj.cxx b/lotuswordpro/source/filter/lwpobj.cxx
index 7e15b62..010b60e 100644
--- a/lotuswordpro/source/filter/lwpobj.cxx
+++ b/lotuswordpro/source/filter/lwpobj.cxx
@@ -64,7 +64,7 @@
  * @descr  construct lwpobject from stream
  */
 LwpObject::LwpObject(LwpObjectHeader objHdr, LwpSvStream* pStrm)
-    : m_ObjHdr(objHdr), m_pObjStrm(NULL), m_pFoundry(NULL), m_pStrm(pStrm)
+    : m_ObjHdr(objHdr), m_pObjStrm(nullptr), m_pFoundry(nullptr), m_pStrm(pStrm), m_bRegisteringStyle(false)
 {
     m_pObjStrm = new LwpObjectStream(pStrm, m_ObjHdr.IsCompressed(),
             static_cast<sal_uInt16>(m_ObjHdr.GetSize()) );
diff --git a/lotuswordpro/source/filter/lwpobj.hxx b/lotuswordpro/source/filter/lwpobj.hxx
index 0cd0025..23ed6b2 100644
--- a/lotuswordpro/source/filter/lwpobj.hxx
+++ b/lotuswordpro/source/filter/lwpobj.hxx
@@ -94,11 +94,22 @@ protected:
     LwpObjectStream* m_pObjStrm;
     LwpFoundry* m_pFoundry;
     LwpSvStream* m_pStrm;
+    bool m_bRegisteringStyle;
 protected:
     virtual void Read();
+    virtual void RegisterStyle();
 public:
     void QuickRead();
-    virtual void RegisterStyle();
+    //calls RegisterStyle but bails if DoRegisterStyle is called
+    //on the same object recursively
+    void DoRegisterStyle()
+    {
+        if (m_bRegisteringStyle)
+            throw std::runtime_error("recursion in styles");
+        m_bRegisteringStyle = true;
+        RegisterStyle();
+        m_bRegisteringStyle = false;
+    }
     virtual void Parse(IXFStream* pOutputStream);
     virtual void XFConvert(XFContentContainer* pCont);
 
diff --git a/lotuswordpro/source/filter/lwppagelayout.cxx b/lotuswordpro/source/filter/lwppagelayout.cxx
index 1a3967c..eff2389 100644
--- a/lotuswordpro/source/filter/lwppagelayout.cxx
+++ b/lotuswordpro/source/filter/lwppagelayout.cxx
@@ -884,7 +884,7 @@ void LwpHeaderLayout::RegisterStyle(XFMasterPage* mp1)
 
         //Call the RegisterStyle first to register the styles in header paras, and then XFConvert()
         pStory->SetFoundry(m_pFoundry);
-        pStory->RegisterStyle();
+        pStory->DoRegisterStyle();
         //, 06/27/2005
         //register child layout style for framelayout,
         RegisterChildStyle();
@@ -1037,8 +1037,7 @@ void LwpFooterLayout::RegisterStyle(XFMasterPage* mp1)
         pChangeMgr->SetHeadFootFribMap(true);
 
         pStory->SetFoundry(m_pFoundry);
-        pStory->RegisterStyle();
-        //, 06/27/2005
+        pStory->DoRegisterStyle();
         //register child layout style for framelayout,
         RegisterChildStyle();
         //End
diff --git a/lotuswordpro/source/filter/lwpvpointer.cxx b/lotuswordpro/source/filter/lwpvpointer.cxx
index 796e0d4..9d1a7dc 100644
--- a/lotuswordpro/source/filter/lwpvpointer.cxx
+++ b/lotuswordpro/source/filter/lwpvpointer.cxx
@@ -77,7 +77,7 @@ void LwpVersionedPointer::RegisterStyle()
     if( pObj.is() )
     {
         pObj->SetFoundry(m_pFoundry);
-        pObj->RegisterStyle();
+        pObj->DoRegisterStyle();
     }
 }
 
commit 2ec7b194747cc79b5c1da697a3d97787949f7f3d
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Dec 9 14:59:17 2015 +0000

    guard against styles based on themselves
    
    which leads to stack exhaustion when queries,
    
    make m_BasedOnStyle private and replace it with
    a call to GetBasedOnStyle which checks that
    the base style is not itself
    
    (cherry picked from commit da5e8ba393b8522a8f7501ebeb1e9a98d544a7ba)
    Reviewed-on: https://gerrit.libreoffice.org/20531
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit 7e5b93bf127aeb83e4ab22e0701b731ec1934253)
    
    Reviewed-on: https://gerrit.libreoffice.org/20532
    Reviewed-by: David Tardon <dtardon at redhat.com>
    Tested-by: David Tardon <dtardon at redhat.com>
    
    Conflicts:
    	lotuswordpro/source/filter/lwplayout.cxx
    
    Change-Id: I093546793755f8a3a6e8a3c23fb8565ad27b75da

diff --git a/lotuswordpro/source/filter/lwpcelllayout.cxx b/lotuswordpro/source/filter/lwpcelllayout.cxx
index 39717cd..c5ac645 100644
--- a/lotuswordpro/source/filter/lwpcelllayout.cxx
+++ b/lotuswordpro/source/filter/lwpcelllayout.cxx
@@ -269,7 +269,7 @@ void LwpCellLayout::ApplyFmtStyle(XFCellStyle *pCellStyle)
     if (!pLayoutNumerics)
     {
         // if current layout doesn't have format, go to based on layout
-        LwpCellLayout* pCellLayout = dynamic_cast<LwpCellLayout*>(m_BasedOnStyle.obj().get());
+        LwpCellLayout* pCellLayout = dynamic_cast<LwpCellLayout*>(GetBasedOnStyle().get());
         if (pCellLayout)
         {
             pLayoutNumerics = dynamic_cast<LwpLayoutNumerics*>(pCellLayout->GetNumericsObject().obj().get());
@@ -656,7 +656,7 @@ void LwpCellLayout::ApplyProtect(XFCell * pCell, LwpObjectID aTableID)
     else
     {
         // judge base on
-        LwpCellLayout * pBase = dynamic_cast<LwpCellLayout *>(m_BasedOnStyle.obj().get());
+        LwpCellLayout * pBase = dynamic_cast<LwpCellLayout *>(GetBasedOnStyle().get());
         if (pBase && pBase->IsProtected())
         {
             bProtected = true;
diff --git a/lotuswordpro/source/filter/lwplayout.cxx b/lotuswordpro/source/filter/lwplayout.cxx
index 594a375..ee89168 100644
--- a/lotuswordpro/source/filter/lwplayout.cxx
+++ b/lotuswordpro/source/filter/lwplayout.cxx
@@ -648,6 +648,17 @@ void LwpMiddleLayout::Read()
     //end
 }
 
+rtl::Reference<LwpObject> LwpMiddleLayout::GetBasedOnStyle()
+{
+    rtl::Reference<LwpObject> xRet(m_BasedOnStyle.obj());
+    if (xRet.get() == this)
+    {
+        SAL_WARN("lwp", "style based on itself");
+        return rtl::Reference<LwpObject>();
+    }
+    return xRet;
+}
+
 #include "lwplaypiece.hxx"
 
 /**
@@ -660,10 +671,9 @@ LwpLayoutGeometry* LwpMiddleLayout::GetGeometry()
     {
         return ( dynamic_cast<LwpLayoutGeometry*> (m_LayGeometry.obj().get()) );
     }
-    else if( !m_BasedOnStyle.IsNull() )
+    else if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*>(GetBasedOnStyle().get()))
     {
-        LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj().get() );
-        return pLay ? pLay->GetGeometry() : NULL;
+        return pLay->GetGeometry();
     }
     return NULL;
 }
@@ -708,11 +718,9 @@ bool LwpMiddleLayout::MarginsSameAsParent()
     {
         return LwpVirtualLayout::MarginsSameAsParent();
     }
-    if(!m_BasedOnStyle.IsNull())
+    if (LwpVirtualLayout* pLay = dynamic_cast<LwpVirtualLayout*> (GetBasedOnStyle().get()))
     {
-        LwpVirtualLayout* pLay = dynamic_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj().get());
-        if (pLay)
-            pLay->MarginsSameAsParent();
+        pLay->MarginsSameAsParent();
     }
     return LwpVirtualLayout::MarginsSameAsParent();
 
@@ -747,7 +755,7 @@ double LwpMiddleLayout::GetMarginsValue(const sal_uInt8 &nWhichSide)
             return fValue;
         }
     }
-    LwpVirtualLayout* pStyle = dynamic_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj().get());
+    LwpVirtualLayout* pStyle = dynamic_cast<LwpVirtualLayout*>(GetBasedOnStyle().get());
     if(pStyle)
     {
         fValue = pStyle->GetMarginsValue(nWhichSide);
@@ -773,7 +781,7 @@ double LwpMiddleLayout::GetExtMarginsValue(const sal_uInt8 &nWhichSide)
             return fValue;
         }
     }
-    LwpVirtualLayout* pStyle = dynamic_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj().get());
+    LwpVirtualLayout* pStyle = dynamic_cast<LwpVirtualLayout*>(GetBasedOnStyle().get());
     if(pStyle)
     {
         fValue = pStyle->GetExtMarginsValue(nWhichSide);
@@ -794,10 +802,9 @@ LwpBorderStuff* LwpMiddleLayout::GetBorderStuff()
         LwpLayoutBorder* pLayoutBorder = dynamic_cast<LwpLayoutBorder*>(m_LayBorderStuff.obj().get());
         return pLayoutBorder ? &pLayoutBorder->GetBorderStuff() : NULL;
     }
-    else if( !m_BasedOnStyle.IsNull() )
+    else if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*>(GetBasedOnStyle().get()))
     {
-        LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj().get() );
-        return pLay ? pLay->GetBorderStuff() :  NULL;
+        return pLay->GetBorderStuff();
     }
     return NULL;
 }
@@ -815,10 +822,9 @@ LwpBackgroundStuff* LwpMiddleLayout::GetBackgroundStuff()
         LwpLayoutBackground* pLayoutBackground = dynamic_cast<LwpLayoutBackground*>(m_LayBackgroundStuff.obj().get());
         return pLayoutBackground ? &pLayoutBackground->GetBackgoudStuff() : NULL;
     }
-    else if( !m_BasedOnStyle.IsNull() )
+    else if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*>(GetBasedOnStyle().get()))
     {
-        LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj().get() );
-        return pLay ? pLay->GetBackgroundStuff() : NULL;
+        return pLay->GetBackgroundStuff();
     }
     return NULL;
 }
@@ -925,10 +931,9 @@ LwpTabOverride* LwpMiddleLayout::GetTabOverride()
         }
         return NULL;
     }
-    else if( !m_BasedOnStyle.IsNull() )
+    else if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( GetBasedOnStyle().get() ))
     {
-        LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj().get() );
-        return pLay ? pLay->GetTabOverride() : NULL;
+        return pLay->GetTabOverride();
     }
     return NULL;
 }
@@ -943,8 +948,9 @@ sal_uInt16 LwpMiddleLayout::GetScaleMode(void)
 {
     if ((m_nOverrideFlag & OVER_SCALING) && m_LayScale.obj().is())
         return GetLayoutScale()->GetScaleMode();
-    else if (m_BasedOnStyle.obj().is())
-        return dynamic_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj().get())->GetScaleMode();
+    rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+    if (xBase.is())
+        return dynamic_cast<LwpMiddleLayout*>(xBase.get())->GetScaleMode();
     else
         return (LwpLayoutScale::FIT_IN_FRAME | LwpLayoutScale::MAINTAIN_ASPECT_RATIO);
 }
@@ -954,8 +960,9 @@ sal_uInt16 LwpMiddleLayout::GetScaleTile(void)
     if ((m_nOverrideFlag & OVER_SCALING) && m_LayScale.obj().is())
         return (GetLayoutScale()->GetPlacement() & LwpLayoutScale::TILED)
             ? 1 : 0;
-    else if (m_BasedOnStyle.obj().is())
-        return dynamic_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj().get())->GetScaleTile();
+    rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+    if (xBase.is())
+        return dynamic_cast<LwpMiddleLayout*>(xBase.get())->GetScaleTile();
     else
         return 0;
 }
@@ -965,8 +972,9 @@ sal_uInt16 LwpMiddleLayout::GetScaleCenter(void)
     if ((m_nOverrideFlag & OVER_SCALING) && m_LayScale.obj().is())
         return (GetLayoutScale()->GetPlacement() & LwpLayoutScale::CENTERED)
             ? 1 : 0;
-    else if (m_BasedOnStyle.obj().is())
-        return dynamic_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj().get())->GetScaleCenter();
+    rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+    if (xBase.is())
+        return dynamic_cast<LwpMiddleLayout*>(xBase.get())->GetScaleCenter();
     else
         return 0;
 }
@@ -975,8 +983,9 @@ sal_uInt32 LwpMiddleLayout::GetScalePercentage(void)
 {
     if ((m_nOverrideFlag & OVER_SCALING) && m_LayScale.obj().is())
         return GetLayoutScale()->GetScalePercentage()/10;//m_nScalePercentage 1000 = 100%
-    else if (m_BasedOnStyle.obj().is())
-        return dynamic_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj().get())->GetScalePercentage();
+    rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+    if (xBase.is())
+        return dynamic_cast<LwpMiddleLayout*>(xBase.get())->GetScalePercentage();
     else
         return 100;
 }
@@ -985,8 +994,9 @@ double LwpMiddleLayout::GetScaleWidth(void)
 {
     if ((m_nOverrideFlag & OVER_SCALING) && m_LayScale.obj().is())
         return LwpTools::ConvertFromUnits(GetLayoutScale()->GetScaleWidth());
-    else if (m_BasedOnStyle.obj().is())
-        return dynamic_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj().get())->GetScaleWidth();
+    rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+    if (xBase.is())
+        return dynamic_cast<LwpMiddleLayout*>(xBase.get())->GetScaleWidth();
     else
         return 0;
 }
@@ -995,8 +1005,9 @@ double LwpMiddleLayout::GetScaleHeight(void)
 {
     if ((m_nOverrideFlag & OVER_SCALING) && m_LayScale.obj().is())
         return LwpTools::ConvertFromUnits(GetLayoutScale()->GetScaleHeight());
-    else if (m_BasedOnStyle.obj().is())
-        return dynamic_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj().get())->GetScaleHeight();
+    rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+    if (xBase.is())
+        return dynamic_cast<LwpMiddleLayout*>(xBase.get())->GetScaleHeight();
     else
         return 0;
 }
@@ -1051,10 +1062,11 @@ bool LwpMiddleLayout::IsSizeRightToContainer(void)
                         << SHIFT_RIGHT))
         == ((LAY_USEDIRECTION | LAY_TOCONTAINER | LAY_AUTOSIZE) << SHIFT_RIGHT);
     }
-    else if (m_BasedOnStyle.obj().is())
+    rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+    if (xBase.is())
     {
-        LwpMiddleLayout * pLayout = dynamic_cast<LwpMiddleLayout *>(m_BasedOnStyle.obj().get());
-        return pLayout ? pLayout->IsSizeRightToContainer() : sal_False;
+        LwpMiddleLayout * pLayout = dynamic_cast<LwpMiddleLayout *>(xBase.get());
+        return pLayout && pLayout->IsSizeRightToContainer();
     }
     else
         return false;
@@ -1070,10 +1082,11 @@ bool LwpMiddleLayout::IsSizeRightToContent(void)
                             << SHIFT_RIGHT))
                 == ((LAY_USEDIRECTION | LAY_AUTOSIZE) << SHIFT_RIGHT);
     }
-    else if (m_BasedOnStyle.obj().is())
+    rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+    if (xBase.is())
     {
-        LwpMiddleLayout * pLayout = dynamic_cast<LwpMiddleLayout *>(m_BasedOnStyle.obj().get());
-        return pLayout ? pLayout->IsSizeRightToContent() : sal_False;
+        LwpMiddleLayout * pLayout = dynamic_cast<LwpMiddleLayout *>(xBase.get());
+        return pLayout && pLayout->IsSizeRightToContent();
     }
     else
         return false;
@@ -1158,15 +1171,13 @@ bool LwpMiddleLayout::IsAutoGrow()
 {
     if(m_nOverrideFlag & OVER_SIZE)
     {
-        return m_nDirection &
+        return (m_nDirection &
             ((LAY_AUTOGROW << SHIFT_UP) | (LAY_AUTOGROW << SHIFT_DOWN) |
-            (LAY_AUTOGROW << SHIFT_RIGHT) | (LAY_AUTOGROW << SHIFT_LEFT))
-            ? sal_True : sal_False;
+            (LAY_AUTOGROW << SHIFT_RIGHT) | (LAY_AUTOGROW << SHIFT_LEFT))) != 0;
     }
-    else if( !m_BasedOnStyle.IsNull() )
+    else if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*>(GetBasedOnStyle().get()))
     {
-        LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj().get() );
-        return pLay ? pLay->IsAutoGrow() : sal_False;
+        return pLay->IsAutoGrow();
     }
     return LwpVirtualLayout::IsAutoGrow();
 }
@@ -1179,12 +1190,11 @@ bool LwpMiddleLayout::IsAutoGrowDown()
 {
     if(m_nOverrideFlag & OVER_SIZE)
     {
-        return m_nDirection & (LAY_AUTOGROW << SHIFT_DOWN) ? sal_True : sal_False;
+        return (m_nDirection & (LAY_AUTOGROW << SHIFT_DOWN)) != 0;
     }
-    else if( !m_BasedOnStyle.IsNull() )
+    else if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*>(GetBasedOnStyle().get()))
     {
-        LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj().get() );
-        return pLay ? pLay->IsAutoGrowDown() : sal_False;
+        return pLay->IsAutoGrowDown();
     }
     return LwpVirtualLayout::IsAutoGrowDown();
 }
@@ -1197,12 +1207,11 @@ bool LwpMiddleLayout::IsAutoGrowUp()
 {
     if(m_nOverrideFlag & OVER_SIZE)
     {
-        return m_nDirection & (LAY_AUTOGROW << SHIFT_UP) ? sal_True : sal_False;
+        return (m_nDirection & (LAY_AUTOGROW << SHIFT_UP)) != 0;
     }
-    else if( !m_BasedOnStyle.IsNull() )
+    else if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*>(GetBasedOnStyle().get()))
     {
-        LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj().get() );
-        return pLay ? pLay->IsAutoGrowUp() : sal_False;
+        return pLay->IsAutoGrowUp();
     }
     return LwpVirtualLayout::IsAutoGrowUp();
 }
@@ -1215,13 +1224,11 @@ bool LwpMiddleLayout::IsAutoGrowLeft()
 {
     if(m_nOverrideFlag & OVER_SIZE)
     {
-        return m_nDirection & (LAY_AUTOGROW << SHIFT_LEFT) ? sal_True : sal_False;
+        return (m_nDirection & (LAY_AUTOGROW << SHIFT_LEFT)) != 0;
     }
-    else if( !m_BasedOnStyle.IsNull() )
+    else if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*>(GetBasedOnStyle().get()))
     {
-        LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj().get() );
-        if (pLay)
-            return pLay->IsAutoGrowLeft();
+        return pLay->IsAutoGrowLeft();
     }
     return LwpVirtualLayout::IsAutoGrowLeft();
 }
@@ -1234,12 +1241,11 @@ bool LwpMiddleLayout::IsAutoGrowRight()
 {
     if(m_nOverrideFlag & OVER_SIZE)
     {
-        return m_nDirection & (LAY_AUTOGROW << SHIFT_RIGHT) ? sal_True : sal_False;
+        return (m_nDirection & (LAY_AUTOGROW << SHIFT_RIGHT)) != 0;
     }
-    else if( !m_BasedOnStyle.IsNull() )
+    else if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> (GetBasedOnStyle().get()))
     {
-        LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj().get() );
-        return pLay ? pLay->IsAutoGrowRight() : sal_False;
+        return pLay->IsAutoGrowRight();
     }
     return LwpVirtualLayout::IsAutoGrowRight();
 }
@@ -1257,11 +1263,9 @@ sal_uInt8 LwpMiddleLayout::GetContentOrientation()
         if (pLayGeometry)
             return pLayGeometry->GetContentOrientation();
     }
-    else if( !m_BasedOnStyle.IsNull() )
+    else if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*>(GetBasedOnStyle().get()))
     {
-        LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj().get() );
-        if (pLay)
-            return pLay->GetContentOrientation();
+        return pLay->GetContentOrientation();
     }
     return LwpVirtualLayout::GetContentOrientation();
 }
@@ -1292,11 +1296,9 @@ bool LwpMiddleLayout::HonorProtection()
             }
         }
     }
-    else if( !m_BasedOnStyle.IsNull() )
+    else if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> (GetBasedOnStyle().get()))
     {
-        LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj().get() );
-        if (pLay)
-            return pLay->HonorProtection();
+        return pLay->HonorProtection();
     }
 
     return LwpVirtualLayout::HonorProtection();
@@ -1313,10 +1315,9 @@ bool LwpMiddleLayout::IsProtected()
     {
         bProtected = (m_nAttributes & STYLE_PROTECTED)!=0;
     }
-    else if( !m_BasedOnStyle.IsNull() )
+    else if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> (GetBasedOnStyle().get()))
     {
-        LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj().get() );
-        bProtected = pLay ? pLay->IsProtected() : sal_False;
+        bProtected = pLay->IsProtected();
     }
     else
         bProtected = LwpVirtualLayout::IsProtected();
@@ -1439,10 +1440,9 @@ bool LwpMiddleLayout::GetUsePrinterSettings()
     {
         return (m_nAttributes3 & STYLE3_USEPRINTERSETTINGS) != 0;
     }
-    else if( !m_BasedOnStyle.IsNull() )
+    else if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> (GetBasedOnStyle().get()))
     {
-        LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj().get() );
-        return pLay ? pLay->GetUsePrinterSettings() : sal_False;
+        return pLay->GetUsePrinterSettings();
     }
     return false;
 }
@@ -1519,8 +1519,8 @@ sal_uInt16 LwpLayout::GetNumCols()
         }
     }
 
-    LwpVirtualLayout* pStyle = dynamic_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj().get());
-    if(pStyle)
+    LwpVirtualLayout* pStyle = dynamic_cast<LwpVirtualLayout*> (GetBasedOnStyle().get());
+    if (pStyle)
     {
         return pStyle->GetNumCols();
     }
@@ -1544,8 +1544,8 @@ double LwpLayout::GetColWidth(sal_uInt16 nIndex)
         }
     }
 
-    LwpVirtualLayout* pStyle = dynamic_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj().get());
-    if(pStyle)
+    LwpVirtualLayout* pStyle = dynamic_cast<LwpVirtualLayout*>(GetBasedOnStyle().get());
+    if (pStyle)
     {
         return pStyle->GetColWidth(nIndex);
     }
@@ -1569,8 +1569,8 @@ double LwpLayout::GetColGap(sal_uInt16 nIndex)
         }
     }
 
-    LwpVirtualLayout* pStyle = dynamic_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj().get());
-    if(pStyle)
+    LwpVirtualLayout* pStyle = dynamic_cast<LwpVirtualLayout*>(GetBasedOnStyle().get());
+    if (pStyle)
     {
         return pStyle->GetColGap(nIndex);
     }
@@ -1719,10 +1719,9 @@ sal_uInt16 LwpLayout::GetUsePage()
         else
             return 0;
     }
-    else if( !m_BasedOnStyle.IsNull() )
+    else if (LwpLayout* pLay = dynamic_cast<LwpLayout*>(GetBasedOnStyle().get()))
     {
-        LwpLayout* pLay = dynamic_cast<LwpLayout*> ( m_BasedOnStyle.obj().get() );
-        return pLay ? pLay->GetUsePage() : 0;
+        return pLay->GetUsePage();
     }
     return 0;
 }
@@ -1737,10 +1736,9 @@ LwpUseWhen* LwpLayout::VirtualGetUseWhen()
     {
         return m_pUseWhen;
     }
-    else if( !m_BasedOnStyle.IsNull() )
+    else if (LwpLayout* pLay = dynamic_cast<LwpLayout*>(GetBasedOnStyle().get()))
     {
-        LwpLayout* pLay = dynamic_cast<LwpLayout*> ( m_BasedOnStyle.obj().get() );
-        return pLay ? pLay->VirtualGetUseWhen() : NULL;
+        return pLay->VirtualGetUseWhen();
     }
     return LwpVirtualLayout::VirtualGetUseWhen();
 }
@@ -1759,11 +1757,9 @@ bool LwpLayout::IsUseOnAllPages()
         else
             return false;
     }
-    else if( !m_BasedOnStyle.IsNull() )
+    else if (LwpLayout* pLay = dynamic_cast<LwpLayout*>(GetBasedOnStyle().get()))
     {
-        LwpLayout* pLay = dynamic_cast<LwpLayout*> ( m_BasedOnStyle.obj().get() );
-        if (pLay)
-            return pLay->IsUseOnAllPages();
+        return pLay->IsUseOnAllPages();
     }
     return LwpVirtualLayout::IsUseOnAllPages();
 }
@@ -1782,11 +1778,9 @@ bool LwpLayout::IsUseOnAllEvenPages()
         else
             return false;
     }
-    else if( !m_BasedOnStyle.IsNull() )
+    else if (LwpLayout* pLay = dynamic_cast<LwpLayout*>(GetBasedOnStyle().get()))
     {
-        LwpLayout* pLay = dynamic_cast<LwpLayout*> ( m_BasedOnStyle.obj().get() );
-        if (pLay)
-            return pLay->IsUseOnAllEvenPages();
+        return pLay->IsUseOnAllEvenPages();
     }
     return LwpVirtualLayout::IsUseOnAllEvenPages();
 }
@@ -1805,11 +1799,9 @@ bool LwpLayout::IsUseOnAllOddPages()
         else
             return false;
     }
-    else if( !m_BasedOnStyle.IsNull() )
+    else if (LwpLayout* pLay = dynamic_cast<LwpLayout*>(GetBasedOnStyle().get()))
     {
-        LwpLayout* pLay = dynamic_cast<LwpLayout*> ( m_BasedOnStyle.obj().get() );
-        if (pLay)
-            return pLay->IsUseOnAllOddPages();
+        return pLay->IsUseOnAllOddPages();
     }
     return LwpVirtualLayout::IsUseOnAllOddPages();
 }
@@ -1828,11 +1820,9 @@ bool LwpLayout::IsUseOnPage()
         else
             return false;
     }
-    else if( !m_BasedOnStyle.IsNull() )
+    else if (LwpLayout* pLay = dynamic_cast<LwpLayout*>(GetBasedOnStyle().get()))
     {
-        LwpLayout* pLay = dynamic_cast<LwpLayout*> ( m_BasedOnStyle.obj().get() );
-        if (pLay)
-            return pLay->IsUseOnPage();
+        return pLay->IsUseOnPage();
     }
     return LwpVirtualLayout::IsUseOnPage();
 }
@@ -1850,10 +1840,9 @@ LwpShadow* LwpLayout::GetShadow()
         LwpLayoutShadow* pLayoutShadow = dynamic_cast<LwpLayoutShadow*>(m_LayShadow.obj().get());
         return pLayoutShadow ? &pLayoutShadow->GetShadow() : NULL;
     }
-    else if( !m_BasedOnStyle.IsNull() )
+    else if (LwpLayout* pLay = dynamic_cast<LwpLayout*>(GetBasedOnStyle().get()))
     {
-        LwpLayout* pLay = dynamic_cast<LwpLayout*> ( m_BasedOnStyle.obj().get() );
-        return pLay ? pLay->GetShadow() : NULL;
+        return pLay->GetShadow();
     }
     return NULL;
 }
@@ -1997,11 +1986,9 @@ sal_uInt8 LwpPlacableLayout::GetWrapType()
     {
         return m_nWrapType;
     }
-    else if( !m_BasedOnStyle.IsNull() )
+    else if (LwpPlacableLayout* pLay = dynamic_cast<LwpPlacableLayout*>(GetBasedOnStyle().get()))
     {
-        LwpPlacableLayout* pLay = dynamic_cast<LwpPlacableLayout*> ( m_BasedOnStyle.obj().get() );
-        if (pLay)
-            return pLay->GetWrapType();
+        return pLay->GetWrapType();
     }
     return LAY_WRAP_AROUND;
 }
@@ -2020,10 +2007,9 @@ LwpLayoutRelativity* LwpPlacableLayout::GetRelativityPiece()
             return dynamic_cast<LwpLayoutRelativity*>(m_LayRelativity.obj().get());
         }
     }
-    else if( !m_BasedOnStyle.IsNull() )
+    else if (LwpPlacableLayout* pLay = dynamic_cast<LwpPlacableLayout*>(GetBasedOnStyle().get()))
     {
-        LwpPlacableLayout* pLay = dynamic_cast<LwpPlacableLayout*> ( m_BasedOnStyle.obj().get() );
-        return pLay ? pLay->GetRelativityPiece() : NULL;
+        return pLay->GetRelativityPiece();
     }
     return NULL;
 }
@@ -2062,10 +2048,9 @@ sal_Int32 LwpPlacableLayout::GetBaseLineOffset()
     {
         return m_nBaseLineOffset;
     }
-    else if( !m_BasedOnStyle.IsNull() )
+    else if (LwpPlacableLayout* pLay = dynamic_cast<LwpPlacableLayout*>(GetBasedOnStyle().get()))
     {
-        LwpPlacableLayout* pLay = dynamic_cast<LwpPlacableLayout*> ( m_BasedOnStyle.obj().get() );
-        return pLay ? pLay->GetBaseLineOffset() : 0;
+        return pLay->GetBaseLineOffset();
     }
     return 0;
 
diff --git a/lotuswordpro/source/filter/lwplayout.hxx b/lotuswordpro/source/filter/lwplayout.hxx
index e1ffb4f..245847e 100644
--- a/lotuswordpro/source/filter/lwplayout.hxx
+++ b/lotuswordpro/source/filter/lwplayout.hxx
@@ -328,6 +328,8 @@ public:
 
 protected:
     void Read() SAL_OVERRIDE;
+private:
+    LwpObjectID m_BasedOnStyle;
 protected:
     enum
     {
@@ -336,8 +338,7 @@ protected:
     };
 
     LwpObjectID m_Content;
-    LwpObjectID m_BasedOnStyle;
-
+    rtl::Reference<LwpObject> GetBasedOnStyle();
     LwpObjectID     m_TabPiece;
     LwpLayoutStyle* m_pStyleStuff;
     LwpLayoutMisc*  m_pMiscStuff;
diff --git a/lotuswordpro/source/filter/lwpobjid.cxx b/lotuswordpro/source/filter/lwpobjid.cxx
index 0c64f91..3729696 100644
--- a/lotuswordpro/source/filter/lwpobjid.cxx
+++ b/lotuswordpro/source/filter/lwpobjid.cxx
@@ -194,12 +194,12 @@ sal_uInt32 LwpObjectID::DiskSize() const
 */
 rtl::Reference<LwpObject> LwpObjectID::obj(VO_TYPE tag) const
 {
-    LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
-    LwpObjectFactory* pObjMgr = pGlobal->GetLwpObjFactory();
-    if(IsNull())
+    if (IsNull())
     {
         return NULL;
     }
+    LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
+    LwpObjectFactory* pObjMgr = pGlobal->GetLwpObjFactory();
     rtl::Reference<LwpObject> pObj = pObjMgr->QueryObject(*this);
     if( tag!=VO_INVALID &&  (pObj.is()) )
     {
commit 23981354b9de4db739440940e9928147f97f00dc
Author: Michael Weghorn <m.weghorn at posteo.de>
Date:   Fri Dec 19 08:47:29 2014 +0100

    fdo#39440 reduce scope of local variables
    
    This addresses some cppcheck warnings.
    
    Change-Id: Idcedd908c653d5a5700884f233ad134dde8be018
    Reviewed-on: https://gerrit.libreoffice.org/13540
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
    Tested-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/lotuswordpro/source/filter/lwpdoc.cxx b/lotuswordpro/source/filter/lwpdoc.cxx
index e126cdc..e3412fc 100644
--- a/lotuswordpro/source/filter/lwpdoc.cxx
+++ b/lotuswordpro/source/filter/lwpdoc.cxx
@@ -257,10 +257,9 @@ void LwpDocument::RegisterLayoutStyles()
 
     //set initial pagelayout in story for parsing pagelayout
     LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*> (m_DivInfo.obj( VO_DIVISIONINFO).get());
-    LwpPageLayout* pPageLayout = NULL;
     if(pDivInfo)
     {
-        pPageLayout = dynamic_cast<LwpPageLayout*>(pDivInfo->GetInitialLayoutID().obj(VO_PAGELAYOUT).get());
+        LwpPageLayout* pPageLayout = dynamic_cast<LwpPageLayout*>(pDivInfo->GetInitialLayoutID().obj(VO_PAGELAYOUT).get());
         if(pPageLayout)
         {
             //In Ole division, the content of pagelayout is VO_OLEOBJECT
@@ -540,11 +539,10 @@ LwpDocument* LwpDocument::GetPreviousDivision()
     }
 
     LwpDocument* pDivision = GetLastDivision();
-    LwpDocument* pContentDivision = NULL;
 
     while(pDivision)
     {
-        pContentDivision = pDivision->GetLastDivisionWithContents();
+        LwpDocument* pContentDivision = pDivision->GetLastDivisionWithContents();
         if(pContentDivision)
         {
             return pContentDivision;
@@ -621,11 +619,9 @@ LwpDocument* LwpDocument::GetPreviousDivision()
 
     LwpDocument* pDivision = GetFirstDivision();
 
-    LwpDocument*  pContentDivision = NULL;
-
     while (pDivision)
     {
-        pContentDivision = pDivision->GetFirstDivisionWithContentsThatIsNotOLE();
+        LwpDocument* pContentDivision = pDivision->GetFirstDivisionWithContentsThatIsNotOLE();
         if(pContentDivision)
             return pContentDivision;
         pDivision = pDivision->GetNextDivision();
diff --git a/lotuswordpro/source/filter/lwpfoundry.cxx b/lotuswordpro/source/filter/lwpfoundry.cxx
index 580f5fd..232afb8 100644
--- a/lotuswordpro/source/filter/lwpfoundry.cxx
+++ b/lotuswordpro/source/filter/lwpfoundry.cxx
@@ -488,7 +488,6 @@ LwpOrderedObject* LwpOrderedObjectManager::Enumerate(LwpOrderedObject * pLast)
 LwpListList* LwpOrderedObjectManager::GetNextActiveListList(LwpListList * pLast)
 {
     LwpListList* pList = NULL;
-    LwpContent* pContent = NULL;
     if(pLast)
         pList = static_cast<LwpListList*>(pLast->GetNext().obj().get());
     else
@@ -502,7 +501,7 @@ LwpListList* LwpOrderedObjectManager::GetNextActiveListList(LwpListList * pLast)
 
     while(pList)
     {
-        pContent = static_cast<LwpContent*>(pList->GetObject().obj().get());
+        LwpContent* pContent = static_cast<LwpContent*>(pList->GetObject().obj().get());
         if(pContent && pContent->HasNonEmbeddedLayouts() &&
             !pContent->IsStyleContent())
             return pList;
diff --git a/lotuswordpro/source/filter/lwplayout.cxx b/lotuswordpro/source/filter/lwplayout.cxx
index 0c5c78d..594a375 100644
--- a/lotuswordpro/source/filter/lwplayout.cxx
+++ b/lotuswordpro/source/filter/lwplayout.cxx
@@ -447,8 +447,6 @@ void LwpAssociatedLayouts::Read(LwpObjectStream* pStrm)
 */
 LwpVirtualLayout* LwpAssociatedLayouts::GetLayout(LwpVirtualLayout *pStartLayout)
 {
-    LwpVirtualLayout* pLayout = NULL;
-
     if (!pStartLayout && !m_OnlyLayout.IsNull())
         /* Looking for the first layout and there's only one layout in  the list.*/
         return dynamic_cast<LwpVirtualLayout*>(m_OnlyLayout.obj().get());
@@ -456,7 +454,7 @@ LwpVirtualLayout* LwpAssociatedLayouts::GetLayout(LwpVirtualLayout *pStartLayout
     LwpObjectHolder* pObjHolder = dynamic_cast<LwpObjectHolder*>(m_Layouts.GetHead().obj().get());
     if(pObjHolder)
     {
-        pLayout = dynamic_cast<LwpVirtualLayout*>(pObjHolder->GetObject().obj().get());
+        LwpVirtualLayout* pLayout = dynamic_cast<LwpVirtualLayout*>(pObjHolder->GetObject().obj().get());
         if(!pStartLayout )
             return pLayout;
 
diff --git a/lotuswordpro/source/filter/lwppagelayout.cxx b/lotuswordpro/source/filter/lwppagelayout.cxx
index ad75b88..1a3967c 100644
--- a/lotuswordpro/source/filter/lwppagelayout.cxx
+++ b/lotuswordpro/source/filter/lwppagelayout.cxx
@@ -719,10 +719,10 @@ LwpPara* LwpPageLayout::GetPagePosition()
     if(pPara)
         return pPara;
     //Get the position from its related section
-    LwpSection* pSection = NULL;
     LwpFoundry* pFoundry = GetFoundry();
     if(pFoundry)
     {
+        LwpSection* pSection = NULL;
         while( (pSection = pFoundry->EnumSections(pSection)) )
         {
             if(pSection->GetPageLayout() == this)
diff --git a/lotuswordpro/source/filter/lwppara.cxx b/lotuswordpro/source/filter/lwppara.cxx
index f1148f9..f7ad9d6 100644
--- a/lotuswordpro/source/filter/lwppara.cxx
+++ b/lotuswordpro/source/filter/lwppara.cxx
@@ -368,11 +368,11 @@ void LwpPara::RegisterStyle()
 
     XFParaStyle* pOverStyle = NULL;
     bool noSpacing = true;
-    bool noIndent = true;
     LwpParaProperty* pBulletProps = NULL, *pNumberingProps = NULL;
 
     if (m_pProps != NULL)
     {
+        bool noIndent = true;
         pOverStyle = new XFParaStyle;
         *pOverStyle = *pBaseStyle;
         pOverStyle->SetStyleName("");
@@ -587,7 +587,6 @@ void LwpPara::RegisterStyle()
                     bool bHeading;
                     LwpPara* pPara = this;
                     LwpPara* pPrePara = NULL;
-                    LwpSilverBullet* pParaSilverBullet = NULL;
                     sal_uInt16 nNum = 0, nLevel = 0, nFoundLevel = 0xffff, nFoundBound = 0;
 
                     nFoundBound = nLevel = pNumbering->GetLevel();
@@ -607,7 +606,7 @@ void LwpPara::RegisterStyle()
                             break;
                         }*/
 
-                        pParaSilverBullet = pPara->GetSilverBullet();
+                        LwpSilverBullet* pParaSilverBullet = pPara->GetSilverBullet();
                         pNumbering = pPara->GetParaNumbering();
 
                         if (pPara->GetObjectID() != this->GetObjectID())
diff --git a/lotuswordpro/source/filter/lwpstory.cxx b/lotuswordpro/source/filter/lwpstory.cxx
index 911e9ae..f4b8eff 100644
--- a/lotuswordpro/source/filter/lwpstory.cxx
+++ b/lotuswordpro/source/filter/lwpstory.cxx
@@ -284,14 +284,13 @@ void LwpStory::SortPageLayout()
 **************************************************************************/
 bool LwpStory::IsNeedSection()
 {
-    bool bColumns = false;
     bool bNewSection = false;
     if(m_pCurrentLayout)
     {
         if(m_pCurrentLayout->HasColumns())
         {
             //get the following pagelayout and its type
-            bColumns = true;
+            bool bColumns = true;
             LwpPageLayout* pNextLayout = GetNextPageLayout();
             if(pNextLayout)
             {
diff --git a/lotuswordpro/source/filter/lwptablelayout.cxx b/lotuswordpro/source/filter/lwptablelayout.cxx
index 6734edb..90897ad 100644
--- a/lotuswordpro/source/filter/lwptablelayout.cxx
+++ b/lotuswordpro/source/filter/lwptablelayout.cxx
@@ -848,7 +848,6 @@ sal_uInt16 LwpTableLayout::ConvertHeadingRow(
 
     sal_uInt16 nRowNum = pTmpTable->GetRowCount();
     sal_uInt8* CellMark = new sal_uInt8[nRowNum];
-    bool bFindFlag = false;
 
     if (nRowNum == 1)
     {
@@ -860,7 +859,7 @@ sal_uInt16 LwpTableLayout::ConvertHeadingRow(
     else
     {
         sal_uInt8 nFirstColSpann = 1;
-        bFindFlag = FindSplitColMark(pTmpTable,CellMark,nFirstColSpann);
+        const bool bFindFlag = FindSplitColMark(pTmpTable,CellMark,nFirstColSpann);
 
         if (bFindFlag)//split to 2 cells
         {
diff --git a/lotuswordpro/source/filter/lwptblformula.cxx b/lotuswordpro/source/filter/lwptblformula.cxx
index 4f6bca0..eda2b45 100644
--- a/lotuswordpro/source/filter/lwptblformula.cxx
+++ b/lotuswordpro/source/filter/lwptblformula.cxx
@@ -310,14 +310,13 @@ bool LwpFormulaInfo::ReadArguments(LwpFormulaFunc& aFunc)
     sal_uInt16 NumberOfArguments = m_pObjStrm->QuickReaduInt16();
     sal_uInt16 ArgumentDiskLength, Count;
     sal_uInt8 ArgumentType;
-    bool bArgument = false;
     bool readSucceeded = true;
 
     for (Count = 0; Count < NumberOfArguments; Count++)
     {
         ArgumentType = (sal_uInt8) m_pObjStrm->QuickReaduInt16(); // written as lushort
         ArgumentDiskLength = m_pObjStrm->QuickReaduInt16();
-        bArgument = true;
+        bool bArgument = true;
 
         switch(ArgumentType)
         {
diff --git a/lotuswordpro/source/filter/xfilter/xfliststyle.cxx b/lotuswordpro/source/filter/xfilter/xfliststyle.cxx
index 14d28b2..6e75c94 100644
--- a/lotuswordpro/source/filter/xfilter/xfliststyle.cxx
+++ b/lotuswordpro/source/filter/xfilter/xfliststyle.cxx
@@ -169,10 +169,9 @@ XFListStyle::XFListStyle()
 
 XFListStyle::XFListStyle(const XFListStyle& other):XFStyle(other)
 {
-    enumXFListLevel type;
     for( int i=0; i<10; i++ )
     {
-        type = other.m_pListLevels[i]->m_eListType;
+        const enumXFListLevel type = other.m_pListLevels[i]->m_eListType;
         if( type == enumXFListLevelNumber )
         {
             XFListlevelNumber *pNum = static_cast<XFListlevelNumber*>(other.m_pListLevels[i]);
@@ -190,10 +189,9 @@ XFListStyle::XFListStyle(const XFListStyle& other):XFStyle(other)
 
 XFListStyle& XFListStyle::operator=(const XFListStyle& other)
 {
-    enumXFListLevel type;
     for( int i=0; i<10; i++ )
     {
-        type = other.m_pListLevels[i]->m_eListType;
+        const enumXFListLevel type = other.m_pListLevels[i]->m_eListType;
         if( type == enumXFListLevelNumber )
         {
             XFListlevelNumber *pNum = static_cast<XFListlevelNumber*>(m_pListLevels[i]);
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index fb747e8..fb36710 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -2547,9 +2547,9 @@ void ChartExport::_exportAxis(
             FSEND );
     }
 
-    bool bDisplayUnits = false;
     if( nAxisType == XML_valAx && GetProperty( xAxisProp, "DisplayUnits" ) )
     {
+        bool bDisplayUnits = false;
         mAny >>= bDisplayUnits;
         if(bDisplayUnits)
         {
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index 5f9c179..fc5ea4e 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -194,7 +194,6 @@ void ZipPackage::parseManifest()
     if ( m_nFormat == embed::StorageFormats::PACKAGE )
     {
         bool bManifestParsed = false;
-        bool bDifferentStartKeyAlgorithm = false;
         const OUString sMeta ("META-INF");
         if ( m_xRootFolder->hasByName( sMeta ) )
         {
@@ -410,6 +409,8 @@ void ZipPackage::parseManifest()
         bool bODF12AndNewer = ( m_pRootFolder->GetVersion().compareTo( ODFVER_012_TEXT ) >= 0 );
         if ( !m_bForceRecovery && bODF12AndNewer )
         {
+            bool bDifferentStartKeyAlgorithm = false;
+
             if ( m_bInconsistent )
             {
                 // this is an ODF1.2 document that contains streams not referred in the manifest.xml;
@@ -575,12 +576,13 @@ void ZipPackage::getZipFileContents()
 void SAL_CALL ZipPackage::initialize( const uno::Sequence< Any >& aArguments )
         throw( Exception, RuntimeException, std::exception )
 {
-    bool bHaveZipFile = true;
     uno::Reference< XProgressHandler > xProgressHandler;
     beans::NamedValue aNamedValue;
 
     if ( aArguments.getLength() )
     {
+        bool bHaveZipFile = true;
+
         for( int ind = 0; ind < aArguments.getLength(); ind++ )
         {
             OUString aParamUrl;
diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx
index 3d44092..0c817fd 100644
--- a/registry/source/regimpl.cxx
+++ b/registry/source/regimpl.cxx
@@ -1612,14 +1612,13 @@ RegError ORegistry::dumpValue(const OUString& sPath, const OUString& sName, sal_
                     sal::static_int_cast< unsigned long >(len));
                 fprintf(stdout, "%s       Data = ", indent);
 
-                sal_Char *pValue;
                 for (sal_uInt32 i=0; i < len; i++)
                 {
                     readUINT32(pBuffer+offset, sLen);
 
                     offset += 4; // 4 Bytes (sal_uInt32) fuer die Groesse des strings in Bytes
 
-                    pValue = (sal_Char*)rtl_allocateMemory(sLen);
+                    sal_Char *pValue = (sal_Char*)rtl_allocateMemory(sLen);
                     readUtf8(pBuffer+offset, pValue, sLen);
 
                     if (offset > 8)
@@ -1650,7 +1649,6 @@ RegError ORegistry::dumpValue(const OUString& sPath, const OUString& sName, sal_
                     sal::static_int_cast< unsigned long >(len));
                 fprintf(stdout, "%s       Data = ", indent);
 
-                sal_Unicode *pValue;
                 OString uStr;
                 for (sal_uInt32 i=0; i < len; i++)
                 {
@@ -1658,7 +1656,7 @@ RegError ORegistry::dumpValue(const OUString& sPath, const OUString& sName, sal_
 
                     offset += 4; // 4 Bytes (sal_uInt32) fuer die Groesse des strings in Bytes
 
-                    pValue = (sal_Unicode*)rtl_allocateMemory((sLen / 2) * sizeof(sal_Unicode));
+                    sal_Unicode *pValue = (sal_Unicode*)rtl_allocateMemory((sLen / 2) * sizeof(sal_Unicode));
                     readString(pBuffer+offset, pValue, sLen);
 
                     if (offset > 8)
diff --git a/registry/source/registry.cxx b/registry/source/registry.cxx
index 803372f..3086adb 100644
--- a/registry/source/registry.cxx
+++ b/registry/source/registry.cxx
@@ -74,11 +74,9 @@ static void REGISTRY_CALLTYPE release(RegHandle hReg)
 
 static RegError REGISTRY_CALLTYPE getName(RegHandle hReg, rtl_uString** pName)
 {
-    ORegistry*  pReg;
-
     if (hReg)
     {
-        pReg = (ORegistry*)hReg;
+        ORegistry*  pReg = (ORegistry*)hReg;
         if ( pReg->isOpen() )
         {
             rtl_uString_assign(pName, pReg->getName().pData);
@@ -580,11 +578,9 @@ REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_openRegistry(rtl_uString* registryN
 
 REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_closeRegistry(RegHandle hRegistry)
 {
-    ORegistry* pReg;
-
     if (hRegistry)
     {
-        pReg = (ORegistry*)hRegistry;
+        ORegistry* pReg = (ORegistry*)hRegistry;
         delete(pReg);
         return REG_NO_ERROR;
     } else
diff --git a/reportdesign/source/core/sdr/RptObject.cxx b/reportdesign/source/core/sdr/RptObject.cxx
index 0d76ae2..f40b8b8 100644
--- a/reportdesign/source/core/sdr/RptObject.cxx
+++ b/reportdesign/source/core/sdr/RptObject.cxx
@@ -710,9 +710,9 @@ void OUnoObject::NbcMove( const Size& rSize )
 
         bool bPositionFixed = false;
         Size aUndoSize(0,0);
-        bool bUndoMode = false;
         if ( m_xReportComponent.is() )
         {
+            bool bUndoMode = false;
             OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
             if (pRptModel->GetUndoEnv().IsUndoMode())
             {
@@ -1006,9 +1006,9 @@ void OOle2Obj::NbcMove( const Size& rSize )
 
         bool bPositionFixed = false;
         Size aUndoSize(0,0);
-        bool bUndoMode = false;
         if ( m_xReportComponent.is() )
         {
+            bool bUndoMode = false;
             OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
             if (pRptModel->GetUndoEnv().IsUndoMode())
             {
diff --git a/reportdesign/source/ui/dlg/Condition.cxx b/reportdesign/source/ui/dlg/Condition.cxx
index 47ea6c0..26e5989 100644
--- a/reportdesign/source/ui/dlg/Condition.cxx
+++ b/reportdesign/source/ui/dlg/Condition.cxx
@@ -122,7 +122,6 @@ OColorPopup::OColorPopup(vcl::Window* _pParent,Condition* _pCondition)
     short i = 0;
     XColorListRef pColorList( XColorList::CreateStdColorList() );
     long nCount = pColorList->Count();
-    XColorEntry* pEntry = NULL;
     Color aColWhite( COL_WHITE );
     OUString aStrWhite( ModuleRes(STR_COLOR_WHITE) );
 
@@ -132,7 +131,7 @@ OColorPopup::OColorPopup(vcl::Window* _pParent,Condition* _pCondition)
 
     for ( i = 0; i < nCount; i++ )
     {
-        pEntry = pColorList->GetColor(i);
+        XColorEntry* pEntry = pColorList->GetColor(i);
         m_aColorSet.InsertItem( i+1, pEntry->GetColor(), pEntry->GetName() );
     }
 
diff --git a/reportdesign/source/ui/dlg/GroupsSorting.cxx b/reportdesign/source/ui/dlg/GroupsSorting.cxx
index dfe9228..171ce37 100644
--- a/reportdesign/source/ui/dlg/GroupsSorting.cxx
+++ b/reportdesign/source/ui/dlg/GroupsSorting.cxx
@@ -403,9 +403,9 @@ bool OFieldExpressionControl::SaveModified(bool _bAppendRow)
     sal_Int32 nRow = GetCurRow();
     if ( nRow != BROWSER_ENDOFSELECTION )
     {
-        bool bAppend = false;
         try
         {
+            bool bAppend = false;
             uno::Reference< report::XGroup> xGroup;
             if ( m_aGroupPositions[nRow] == NO_GROUP )
             {
diff --git a/reportdesign/source/ui/report/ReportSection.cxx b/reportdesign/source/ui/report/ReportSection.cxx
index 6b61162..e7e2f53 100644
--- a/reportdesign/source/ui/report/ReportSection.cxx
+++ b/reportdesign/source/ui/report/ReportSection.cxx
@@ -547,7 +547,6 @@ void OReportSection::impl_adjustObjectSizePosition(sal_Int32 i_nPaperWidth,sal_I
         const sal_Int32 nCount = m_xSection->getCount();
         for (sal_Int32 i = 0; i < nCount; ++i)
         {
-            bool bChanged = false;
             uno::Reference< report::XReportComponent> xReportComponent(m_xSection->getByIndex(i),uno::UNO_QUERY_THROW);
             awt::Point aPos = xReportComponent->getPosition();
             awt::Size aSize = xReportComponent->getSize();
@@ -555,6 +554,8 @@ void OReportSection::impl_adjustObjectSizePosition(sal_Int32 i_nPaperWidth,sal_I
             SdrObject* pObject = pShape ? pShape->GetSdrObject() : NULL;
             if ( pObject )
             {
+                bool bChanged = false;
+
                 OObjectBase& rBase = dynamic_cast<OObjectBase&>(*pObject);
                 rBase.EndListening(false);
                 if ( aPos.X < i_nLeftMargin )
commit f260e41f010dcc5256a43f9c44cc47b6d844bd97
Author: David Tardon <dtardon at redhat.com>
Date:   Thu Dec 10 10:04:50 2015 +0100

    add missing #include <stdexcept>
    
    Change-Id: I9cf72b27219489a5508786881ecd95e5820c71ac
    (cherry picked from commit 1ff0a3880c48227656d2b4a823cd66a6d5c74af0)
    Signed-off-by: David Tardon <dtardon at redhat.com>

diff --git a/lotuswordpro/source/filter/lwpobj.hxx b/lotuswordpro/source/filter/lwpobj.hxx
index 942e044..0cd0025 100644
--- a/lotuswordpro/source/filter/lwpobj.hxx
+++ b/lotuswordpro/source/filter/lwpobj.hxx
@@ -67,6 +67,8 @@
 
 #include <sal/config.h>
 
+#include <stdexcept>
+
 #include <salhelper/simplereferenceobject.hxx>
 
 #include "lwpheader.hxx"
commit 6d5dded7610c72794374ceceab348229ba8316e5
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Dec 9 16:58:16 2015 +0000

    bounds check GetNameByIndex like Override
    
    Change-Id: If83e255da1683779458556a3ab1af4f00b19265b
    (cherry picked from commit 8c67b1b51f21643036c5f5371a6af0a4558e7da2)
    Reviewed-on: https://gerrit.libreoffice.org/20547
    Reviewed-by: David Tardon <dtardon at redhat.com>
    Tested-by: David Tardon <dtardon at redhat.com>

diff --git a/lotuswordpro/source/filter/lwpfont.cxx b/lotuswordpro/source/filter/lwpfont.cxx
index 3ee7e1b..4307d29 100644
--- a/lotuswordpro/source/filter/lwpfont.cxx
+++ b/lotuswordpro/source/filter/lwpfont.cxx
@@ -399,8 +399,13 @@ void    LwpFontNameManager::Override(sal_uInt16 index, rtl::Reference<XFFont> co
     if(m_pFontNames[index-1].IsAltFaceNameOverridden())
         pFont->SetFontNameAsia(m_FontTbl.GetFaceName(m_pFontNames[index-1].GetAltFaceID()));
 }
+
 OUString LwpFontNameManager::GetNameByIndex(sal_uInt16 index)
+    //index: start from 1
 {
+    if (index > m_nCount || index < 1)
+        return OUString();
+
     sal_uInt16 nameindex = m_pFontNames[index-1].GetFaceID();
     return (m_FontTbl.GetFaceName(nameindex));
 }
commit 2041973b75d3a81bb2632f17369c79e68d4c40a0
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Dec 9 16:48:29 2015 +0000

    guard against missing alignment property
    
    (cherry picked from commit 7e341379ecec218c0ff2ff0e8db9f14468b125f6)
    Reviewed-on: https://gerrit.libreoffice.org/20543
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit 3b9e2bb22e782d073d8e67ae975ebb8ca5eea552)
    
    Change-Id: I1d4825c2136e516baf759f4b2c40c911547b93d7
    Reviewed-on: https://gerrit.libreoffice.org/20544
    Reviewed-by: David Tardon <dtardon at redhat.com>
    Tested-by: David Tardon <dtardon at redhat.com>

diff --git a/lotuswordpro/source/filter/lwppara.cxx b/lotuswordpro/source/filter/lwppara.cxx
index 68ada79..f1148f9 100644
--- a/lotuswordpro/source/filter/lwppara.cxx
+++ b/lotuswordpro/source/filter/lwppara.cxx
@@ -386,18 +386,22 @@ void LwpPara::RegisterStyle()
             {
             case PP_LOCAL_ALIGN:
             {
-                if (!rParaStyle.GetAlignment())
-                    OverrideAlignment(NULL,static_cast<LwpParaAlignProperty*>(pProps)->GetAlignment(),pOverStyle);
-                else
+                LwpAlignmentOverride *pAlignment = static_cast<LwpParaAlignProperty*>(pProps)->GetAlignment();
+                if (pAlignment)
                 {
-                    boost::scoped_ptr<LwpAlignmentOverride> const pAlign(
-                            rParaStyle.GetAlignment()->clone());
-                    OverrideAlignment(pAlign.get(),
-                            static_cast<LwpParaAlignProperty*>(pProps)->GetAlignment(),
-                            pOverStyle);
+                    if (!rParaStyle.GetAlignment())
+                        OverrideAlignment(nullptr, pAlignment, pOverStyle);
+                    else
+                    {
+                        std::unique_ptr<LwpAlignmentOverride> const pAlign(
+                                rParaStyle.GetAlignment()->clone());
+                        OverrideAlignment(pAlign.get(),
+                                pAlignment,
+                                pOverStyle);
+                    }
                 }
-            }
                 break;
+            }
             case PP_LOCAL_INDENT:
             {
                 noIndent = false;
commit 3d9601fdeaba898b833d0160c2c461faf0e987c6
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Dec 9 16:41:26 2015 +0000

    guard against missing SuperTable
    
    Change-Id: Ic7cc6c807905e0c4ffbf2a3f009b27be6100cdf0
    (cherry picked from commit 0cde3ca230364492aa6b7f634b97178164268728)
    Reviewed-on: https://gerrit.libreoffice.org/20541
    Reviewed-by: David Tardon <dtardon at redhat.com>
    Tested-by: David Tardon <dtardon at redhat.com>

diff --git a/lotuswordpro/source/filter/lwpfribtable.cxx b/lotuswordpro/source/filter/lwpfribtable.cxx
index 4adb3ac..86c70ea 100644
--- a/lotuswordpro/source/filter/lwpfribtable.cxx
+++ b/lotuswordpro/source/filter/lwpfribtable.cxx
@@ -78,7 +78,9 @@ LwpSuperTableLayout* LwpFribTable::GetSuperTable()
 
 void LwpFribTable::RegisterNewStyle()
 {
-    GetSuperTable()->RegisterNewStyle();
+    LwpSuperTableLayout* pSuper = GetSuperTable();
+    if (pSuper)
+        pSuper->RegisterNewStyle();
     XFParaStyle* pOldStyle = m_pPara->GetXFParaStyle();
     if(HasNextFrib())
     {
commit 09c9abccc01c64f68033e8b994fa5418abf7cd61
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Dec 9 16:31:40 2015 +0000

    guard against missing paragraph story
    
    Change-Id: I217c0aedca4eadc347c103899d96c70cf9606038
    (cherry picked from commit dbc830aecc722d34971d773470da478ef4c38714)
    Reviewed-on: https://gerrit.libreoffice.org/20539
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/lotuswordpro/source/filter/lwpfribsection.cxx b/lotuswordpro/source/filter/lwpfribsection.cxx
index b870488..e24faf8 100644
--- a/lotuswordpro/source/filter/lwpfribsection.cxx
+++ b/lotuswordpro/source/filter/lwpfribsection.cxx
@@ -164,9 +164,8 @@ void LwpFribSection::ParseSection()
             m_pMasterPage->ParseSection(this);
         }
     }
-    else
+    else if (LwpStory* pStory = static_cast<LwpStory*>(m_pPara->GetStoryID().obj().get()))
     {
-        LwpStory* pStory = static_cast<LwpStory*> ( m_pPara->GetStoryID().obj().get() );
         rtl::Reference<LwpObject> xObj(m_Section.obj());
         if (xObj.is() && xObj->GetTag() == VO_INDEXSECTION)
         {
commit 1b1a4b5e57d3ae2d855cf4f98a1b0ae29abebd08
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Dec 9 16:21:38 2015 +0000

    guard against missing indent property
    
    (cherry picked from commit ae94fc5b28105c920b2e9d336f463b27cae5b0e1)
    Reviewed-on: https://gerrit.libreoffice.org/20535
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit d9f6f9063d34f29eb44d82159c411646dc19c83f)
    
    Change-Id: I2d3369aed4b242acc936a71ee9be573c1ebc7a8f
    Reviewed-on: https://gerrit.libreoffice.org/20536
    Reviewed-by: David Tardon <dtardon at redhat.com>
    Tested-by: David Tardon <dtardon at redhat.com>

diff --git a/lotuswordpro/source/filter/lwppara.cxx b/lotuswordpro/source/filter/lwppara.cxx
index 0f6f8bc..68ada79 100644
--- a/lotuswordpro/source/filter/lwppara.cxx
+++ b/lotuswordpro/source/filter/lwppara.cxx
@@ -401,15 +401,16 @@ void LwpPara::RegisterStyle()
             case PP_LOCAL_INDENT:
             {
                 noIndent = false;
-                if (!rParaStyle.GetIndent())
-                    OverrideIndent(NULL,static_cast<LwpParaIndentProperty*>(pProps)->GetIndent(),pOverStyle);
-
-                else
+                LwpIndentOverride *pIndent = static_cast<LwpParaIndentProperty*>(pProps)->GetIndent();
+                if (pIndent)
                 {
-                    OverrideIndent(m_pIndentOverride,static_cast<LwpParaIndentProperty*>(pProps)->GetIndent(),pOverStyle);
+                    if (!rParaStyle.GetIndent())
+                        OverrideIndent(nullptr, pIndent, pOverStyle);
+                    else
+                        OverrideIndent(m_pIndentOverride, pIndent, pOverStyle);
                 }
-            }
                 break;
+            }
             case PP_LOCAL_SPACING:
             {
                 noSpacing = false;
commit 9db3b29ba41ba705a29ab2be8126dd7507b764d5
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Dec 9 13:30:02 2015 +0000

    guard against no default text style
    
    Change-Id: I7416d709de79ae88cf4a9546d8adfecec9935238
    (cherry picked from commit 80297dd0f21bfeaa9bae09cacfa29ab2eee64c09)
    Reviewed-on: https://gerrit.libreoffice.org/20529
    Reviewed-by: David Tardon <dtardon at redhat.com>
    Tested-by: David Tardon <dtardon at redhat.com>

diff --git a/lotuswordpro/source/filter/lwptoc.cxx b/lotuswordpro/source/filter/lwptoc.cxx
index f6fed09..35b6a25 100644
--- a/lotuswordpro/source/filter/lwptoc.cxx
+++ b/lotuswordpro/source/filter/lwptoc.cxx
@@ -130,7 +130,8 @@ void LwpTocSuperLayout::RegisterStyle()
     LwpSuperTableLayout::RegisterStyle();
 
     // Get font info of default text style and set into tab style
-    XFParaStyle* pBaseStyle = static_cast<XFParaStyle*>(m_pFoundry->GetStyleManager()->GetStyle(*m_pFoundry->GetDefaultTextStyle()));
+    const LwpObjectID *pDefaultTextStyle = m_pFoundry->GetDefaultTextStyle();
+    XFParaStyle* pBaseStyle = pDefaultTextStyle ? static_cast<XFParaStyle*>(m_pFoundry->GetStyleManager()->GetStyle(*pDefaultTextStyle)) : nullptr;
     XFTextStyle*pTextStyle = new XFTextStyle;
     if (pBaseStyle)
         pTextStyle->SetFont(pBaseStyle->GetFont()); // who delete this font?????
commit c03f1911d953b0bde0347b61ada60f00b295ecbf
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Dec 9 13:10:27 2015 +0000

    guard against missing paragraph Story
    
    Change-Id: Iae617e9731dbdcedf8aa6bf02977911dce60bdd0
    (cherry picked from commit 9d2a1c48b4a39967bc21776b471f1a4eca735cb6)
    Reviewed-on: https://gerrit.libreoffice.org/20526
    Reviewed-by: David Tardon <dtardon at redhat.com>
    Tested-by: David Tardon <dtardon at redhat.com>

diff --git a/lotuswordpro/source/filter/lwpfribptr.cxx b/lotuswordpro/source/filter/lwpfribptr.cxx
index 4f3211a..79486a2 100644
--- a/lotuswordpro/source/filter/lwpfribptr.cxx
+++ b/lotuswordpro/source/filter/lwpfribptr.cxx
@@ -269,9 +269,9 @@ void LwpFribPtr::XFConvert()
         case FRIB_TAG_HARDSPACE:
         {
             OUString sHardSpace(sal_Unicode(0x00a0));
-            LwpHyperlinkMgr* pHyperlink =
-                    m_pPara->GetStory()->GetHyperlinkMgr();
-            if (pHyperlink->GetHyperlinkFlag())
+            LwpStory *pStory = m_pPara->GetStory();
+            LwpHyperlinkMgr* pHyperlink = pStory ? pStory->GetHyperlinkMgr() : nullptr;
+            if (pHyperlink && pHyperlink->GetHyperlinkFlag())
                 pFrib->ConvertHyperLink(m_pXFPara,pHyperlink,sHardSpace);
             else
                 pFrib->ConvertChars(m_pXFPara,sHardSpace);
commit b9ab690495bf3f870b621fa82f526c79fdcc5f21
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Dec 9 13:00:24 2015 +0000

    guard against missing BaseStyle
    
    Change-Id: I173b12f0a28f917f24d1923e531da1b798beb1f6
    (cherry picked from commit d34cbe279cc8e1db941a4da1130d5a6d7429357d)
    Reviewed-on: https://gerrit.libreoffice.org/20523
    Reviewed-by: David Tardon <dtardon at redhat.com>
    Tested-by: David Tardon <dtardon at redhat.com>

diff --git a/lotuswordpro/source/filter/lwptoc.cxx b/lotuswordpro/source/filter/lwptoc.cxx
index 2020e93..f6fed09 100644
--- a/lotuswordpro/source/filter/lwptoc.cxx
+++ b/lotuswordpro/source/filter/lwptoc.cxx
@@ -132,7 +132,8 @@ void LwpTocSuperLayout::RegisterStyle()
     // Get font info of default text style and set into tab style
     XFParaStyle* pBaseStyle = static_cast<XFParaStyle*>(m_pFoundry->GetStyleManager()->GetStyle(*m_pFoundry->GetDefaultTextStyle()));
     XFTextStyle*pTextStyle = new XFTextStyle;
-    pTextStyle->SetFont(pBaseStyle->GetFont()); // who delete this font?????
+    if (pBaseStyle)
+        pTextStyle->SetFont(pBaseStyle->GetFont()); // who delete this font?????
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
     m_TabStyleName = pXFStyleManager->AddStyle(pTextStyle).m_pStyle->GetStyleName();
 
commit 1795c4eda3e0a76fa4983e4e41471c4547e3080c
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Dec 9 12:50:57 2015 +0000

    guard against missing Section
    
    Change-Id: Id5295d294b56d6504d962ee1941a350a595031e7
    (cherry picked from commit c8b4fe55b8b50fc33a9157e93b42aed0f7d30534)
    Reviewed-on: https://gerrit.libreoffice.org/20520
    Reviewed-by: David Tardon <dtardon at redhat.com>
    Tested-by: David Tardon <dtardon at redhat.com>

diff --git a/lotuswordpro/source/filter/lwpfribsection.cxx b/lotuswordpro/source/filter/lwpfribsection.cxx
index f66b00f..b870488 100644
--- a/lotuswordpro/source/filter/lwpfribsection.cxx
+++ b/lotuswordpro/source/filter/lwpfribsection.cxx
@@ -167,7 +167,8 @@ void LwpFribSection::ParseSection()
     else
     {
         LwpStory* pStory = static_cast<LwpStory*> ( m_pPara->GetStoryID().obj().get() );
-        if (m_Section.obj()->GetTag() == VO_INDEXSECTION)
+        rtl::Reference<LwpObject> xObj(m_Section.obj());
+        if (xObj.is() && xObj->GetTag() == VO_INDEXSECTION)
         {
             //create a new section and add it to container
             XFIndex* pIndex = new XFIndex;
commit ca80207af0ba35d9e309ff911536dcaf09c00e01
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Dec 9 12:41:48 2015 +0000

    guard against missing RootDocument
    
    Change-Id: I1c6b58b58ab489a17419dbf7cd4ecec63359b7f3
    (cherry picked from commit 0f700d5bc9c0ebc1e1ebe60758fbbf02590790bc)
    Reviewed-on: https://gerrit.libreoffice.org/20516
    Reviewed-by: David Tardon <dtardon at redhat.com>
    Tested-by: David Tardon <dtardon at redhat.com>

diff --git a/lotuswordpro/source/filter/lwpdoc.cxx b/lotuswordpro/source/filter/lwpdoc.cxx
index e2ab2a7..e126cdc 100644
--- a/lotuswordpro/source/filter/lwpdoc.cxx
+++ b/lotuswordpro/source/filter/lwpdoc.cxx
@@ -638,8 +638,8 @@ LwpDocument* LwpDocument::GetPreviousDivision()
  LwpDocument* LwpDocument::GetLastDivisionThatHasEndnote()
 {
     LwpDocument* pRoot = GetRootDocument();
-    LwpDocument *pLastDoc = pRoot->GetLastDivisionWithContents();
-    while(pLastDoc)
+    LwpDocument *pLastDoc = pRoot ? pRoot->GetLastDivisionWithContents() : nullptr;
+    while (pLastDoc)
     {
         if(pLastDoc->GetEnSuperTableLayout())
             return pLastDoc;
commit 268954733b1160c934acc5e33bd8f1dfa121adaa
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Dec 9 12:33:36 2015 +0000

    protect against missing Modifiers
    
    Change-Id: I226f67c6c49bfcbc1fa0ef40fc9f7d5548fa043b
    (cherry picked from commit 6c59adca37900dccc394061a730984ecb180aacf)
    Reviewed-on: https://gerrit.libreoffice.org/20511
    Reviewed-by: David Tardon <dtardon at redhat.com>
    Tested-by: David Tardon <dtardon at redhat.com>

diff --git a/lotuswordpro/source/filter/lwppara1.cxx b/lotuswordpro/source/filter/lwppara1.cxx
index bba1506..bcf81fe 100644
--- a/lotuswordpro/source/filter/lwppara1.cxx
+++ b/lotuswordpro/source/filter/lwppara1.cxx
@@ -241,7 +241,7 @@ void LwpPara::GetParaNumber(sal_uInt16 nPosition, ParaNumbering* pParaNumbering)
                         {
                             if (
                                  (pFrib->GetNext() && pFrib->GetNext()->GetType() == FRIB_TAG_TEXT) ||
-                                 (pFrib->GetModifiers()->aTxtAttrOverride.GetHideLevels() == nHideLevels)
+                                 (pFrib->GetModifiers() && pFrib->GetModifiers()->aTxtAttrOverride.GetHideLevels() == nHideLevels)
                                )
                             {
                                 pParaNumbering->pSuffix = static_cast<LwpFribText*>(pFrib);
commit 94c7e0a7117952552dd3238f1ee6fd504200e244
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Dec 9 12:23:11 2015 +0000

    protect against missing SuperTable
    
    Change-Id: I788ec28424bb638f727901b7d25e48a284ab67d0
    (cherry picked from commit 356109d4ead137ea22b358b20ed22a4bd09d35f6)
    Reviewed-on: https://gerrit.libreoffice.org/20508
    Reviewed-by: David Tardon <dtardon at redhat.com>
    Tested-by: David Tardon <dtardon at redhat.com>

diff --git a/lotuswordpro/source/filter/lwpfribtable.cxx b/lotuswordpro/source/filter/lwpfribtable.cxx
index edd73da..4adb3ac 100644
--- a/lotuswordpro/source/filter/lwpfribtable.cxx
+++ b/lotuswordpro/source/filter/lwpfribtable.cxx
@@ -98,6 +98,8 @@ void LwpFribTable::XFConvert(XFContentContainer* pCont)
 {
     XFContentContainer* pXFContentContainer = pCont;
     LwpSuperTableLayout* pSuper = GetSuperTable();
+    if (!pSuper)
+        return;
     sal_uInt8 nType = pSuper->GetRelativeType();
     LwpVirtualLayout* pContainer = pSuper->GetContainerLayout();
     if (!pContainer)
commit d4854f092cebf6490bfdff0f9209de0fac76c3eb
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Dec 9 12:09:37 2015 +0000

    guard against corrupt SilverBullet
    
    (cherry picked from commit 36d55980b1b3498fecc460d3c46667e5f5a17b8e)
    Reviewed-on: https://gerrit.libreoffice.org/20504
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit d387a99fce3f96f4fcd60c70909292255f12840f)
    
    Change-Id: I3af47ab3af5e28a865a77a592f6a92edb46e4f2b
    Reviewed-on: https://gerrit.libreoffice.org/20505
    Reviewed-by: David Tardon <dtardon at redhat.com>
    Tested-by: David Tardon <dtardon at redhat.com>

diff --git a/lotuswordpro/source/filter/lwpsilverbullet.cxx b/lotuswordpro/source/filter/lwpsilverbullet.cxx
index c0c39e9..e7ad33f 100644
--- a/lotuswordpro/source/filter/lwpsilverbullet.cxx
+++ b/lotuswordpro/source/filter/lwpsilverbullet.cxx
@@ -97,7 +97,10 @@ void LwpSilverBullet::Read()
 
     sal_uInt16 nNumPos = m_pObjStrm->QuickReaduInt16();
 
-    for (sal_uInt8 nC = 0; nC < nNumPos; nC++)
+    if (nNumPos > SAL_N_ELEMENTS(m_pResetPositionFlags))
+        throw std::range_error("corrupt SilverBullet");
+
+    for (sal_uInt16 nC = 0; nC < nNumPos; nC++)
         m_pResetPositionFlags[nC] = m_pObjStrm->QuickReaduInt8();
 
     m_nUseCount = m_pObjStrm->QuickReaduInt32();
commit c4ebf3580d26db69c5c3997634f1d95596676a01
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Dec 9 11:56:52 2015 +0000

    guard against corrupt ObjIndexData
    
    Change-Id: I214991e5d34c8e335cdd8ea482f8fa4913ba637b
    (cherry picked from commit c88a23b9d44118e96de41a70ab7f87eb0aafb126)
    Reviewed-on: https://gerrit.libreoffice.org/20502
    Reviewed-by: David Tardon <dtardon at redhat.com>
    Tested-by: David Tardon <dtardon at redhat.com>

diff --git a/lotuswordpro/source/filter/lwpidxmgr.cxx b/lotuswordpro/source/filter/lwpidxmgr.cxx
index d6720e7..43208ab 100644
--- a/lotuswordpro/source/filter/lwpidxmgr.cxx
+++ b/lotuswordpro/source/filter/lwpidxmgr.cxx
@@ -215,7 +215,7 @@ void LwpIndexManager::ReadObjIndexData(LwpObjectStream* pObjStrm)
             vObjIndexs[k]->offset = pObjStrm->QuickReaduInt32();
 
         for (k = 0; k < LeafCount; k++)
-            m_TempVec[k] = pObjStrm->QuickReaduInt32();
+            m_TempVec.at(k) = pObjStrm->QuickReaduInt32();
     }
 
     for( sal_uInt16 j=0; j<LeafCount; j++ )
diff --git a/lotuswordpro/source/filter/lwpobjstrm.cxx b/lotuswordpro/source/filter/lwpobjstrm.cxx
index 8eb8d43..2836fad 100644
--- a/lotuswordpro/source/filter/lwpobjstrm.cxx
+++ b/lotuswordpro/source/filter/lwpobjstrm.cxx
@@ -170,7 +170,7 @@ sal_uInt16 LwpObjectStream::QuickRead(void* buf, sal_uInt16 len)
     memset(buf, 0, len);
     if( len > m_nBufSize - m_nReadPos )
     {
-        assert(false);
+        SAL_WARN("lwp", "read request longer than buffer");
         len = m_nBufSize - m_nReadPos;
     }
     if( m_pContentBuf && len)
commit e9860b154d300ccf1827b6d5fd3f9ed0c53972cd
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Dec 9 11:28:52 2015 +0000

    guard against corrupt RootData
    
    Change-Id: Iad2788a7e5e7ee3b3107eab37cde2d3d38eae005
    (cherry picked from commit fc943ea85a7924ce0552b08eef99ed8e02f0b965)
    Reviewed-on: https://gerrit.libreoffice.org/20496
    Reviewed-by: David Tardon <dtardon at redhat.com>
    Tested-by: David Tardon <dtardon at redhat.com>

diff --git a/lotuswordpro/source/filter/lwpidxmgr.cxx b/lotuswordpro/source/filter/lwpidxmgr.cxx
index 07ea4a1..d6720e7 100644
--- a/lotuswordpro/source/filter/lwpidxmgr.cxx
+++ b/lotuswordpro/source/filter/lwpidxmgr.cxx
@@ -154,7 +154,10 @@ void LwpIndexManager::ReadRootData(LwpObjectStream* pObjStrm)
     sal_uInt16 KeyCount = pObjStrm->QuickReaduInt16();
     m_nLeafCount = KeyCount ? KeyCount + 1 : 0;
 
-    if(KeyCount)
+    if (m_nLeafCount > SAL_N_ELEMENTS(m_ChildIndex))
+        throw std::range_error("corrupt RootData");
+
+    if (KeyCount)
     {
         //read object keys
         LwpKey* akey = new LwpKey();
diff --git a/lotuswordpro/source/filter/lwptabrack.cxx b/lotuswordpro/source/filter/lwptabrack.cxx
index 0dac754..487d387 100644
--- a/lotuswordpro/source/filter/lwptabrack.cxx
+++ b/lotuswordpro/source/filter/lwptabrack.cxx
@@ -92,7 +92,7 @@ void LwpTabRack::Read()
 
     m_nNumTabs = m_pObjStrm->QuickReaduInt16();
     if (m_nNumTabs > MaxTabs)
-        throw std::out_of_range("corrupt LwpTabRack");
+        throw std::range_error("corrupt LwpTabRack");
     for (int i=0; i<m_nNumTabs; ++i)
     {
         m_aTabs[i].Read(m_pObjStrm);
commit 24d44b325e0d9a60dff90c80bbbc35c9ed4d1d98
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Dec 8 22:11:13 2015 +0100

    lotuswordpro: GCC 4.6 seems to need stdexcept included
    
    Change-Id: I30bbf7bab8cb37422fd20a25741e564500faa31c
    (cherry picked from commit 742c2370566bf1e7caa7403c99f088a79ae146fa)

diff --git a/lotuswordpro/source/filter/lwptabrack.cxx b/lotuswordpro/source/filter/lwptabrack.cxx
index 8295796..0dac754 100644
--- a/lotuswordpro/source/filter/lwptabrack.cxx
+++ b/lotuswordpro/source/filter/lwptabrack.cxx
@@ -61,6 +61,8 @@
 #include "lwpobjstrm.hxx"
 #include "lwpslvlist.hxx"
 
+#include <stdexcept>
+
 LwpTab::LwpTab()
 {
     m_nX = 0;
commit c4dd2c414064087237feafa557286d3518ca8c72
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Dec 8 20:38:44 2015 +0000

    valgrind: jump or move depends on uninitialised value
    
    Change-Id: I02e507f4b7d78efacc5b735ca24adb83633749b9
    (cherry picked from commit dcbef55a111405b4540856bf6910f81bce9785bb)
    Reviewed-on: https://gerrit.libreoffice.org/20479
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>

diff --git a/lotuswordpro/source/filter/lwpfilter.cxx b/lotuswordpro/source/filter/lwpfilter.cxx
index 9e66d7b..9db5f3f 100644
--- a/lotuswordpro/source/filter/lwpfilter.cxx
+++ b/lotuswordpro/source/filter/lwpfilter.cxx
@@ -148,8 +148,8 @@ using namespace OpenStormBento;
 {
     SvStream * pDecompressed = NULL;
 
-    sal_uInt32 nTag;
     pStream->Seek(0x10);
+    sal_uInt32 nTag(0);
     pStream->ReadUInt32( nTag );
     if (nTag != 0x3750574c) // "LWP7"
     {
commit 59c857aee4a642f826bb4c9d248b0e306eea1b54
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Dec 8 14:20:52 2015 +0000

    guard against corrupt m_nNumTabs
    
    Change-Id: I41b8514a127d463ac951e5855f09416fa0456b1b
    (cherry picked from commit 85a2cd37fc60cd53a892b27a18d4b5272988361c)
    (cherry picked from commit 34a03c676e618200292f187f8f96b74f23c962b5)
    Reviewed-on: https://gerrit.libreoffice.org/20471
    Reviewed-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>
    Tested-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>

diff --git a/lotuswordpro/source/filter/lwptabrack.cxx b/lotuswordpro/source/filter/lwptabrack.cxx
index 5c3eb44..8295796 100644
--- a/lotuswordpro/source/filter/lwptabrack.cxx
+++ b/lotuswordpro/source/filter/lwptabrack.cxx
@@ -86,11 +86,12 @@ LwpTabRack::LwpTabRack(LwpObjectHeader objHdr, LwpSvStream* pStrm):LwpObject(obj
 
 void LwpTabRack::Read()
 {
-//  LwpObjectID     m_NextID;
     m_NextID.ReadIndexed(m_pObjStrm);
 
     m_nNumTabs = m_pObjStrm->QuickReaduInt16();
-    for( int i=0; i<m_nNumTabs; i++ )
+    if (m_nNumTabs > MaxTabs)
+        throw std::out_of_range("corrupt LwpTabRack");
+    for (int i=0; i<m_nNumTabs; ++i)
     {
         m_aTabs[i].Read(m_pObjStrm);
         m_pObjStrm->SkipExtra();
commit cacad05ac0c7a7a775503423c4dcb56524660f29
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 8 10:50:23 2015 +0100

    Resolves: tdf#93818 crash on loading certain lwp
    
    Change-Id: I11f523a0936b843155f3b47139d0fc58d4d0342b
    (cherry picked from commit cc1273543f4084a779a2b0400c22466672557a95)
    Reviewed-on: https://gerrit.libreoffice.org/19242
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/lotuswordpro/source/filter/lwpfrib.cxx b/lotuswordpro/source/filter/lwpfrib.cxx
index bc404aa..138d206 100644
--- a/lotuswordpro/source/filter/lwpfrib.cxx
+++ b/lotuswordpro/source/filter/lwpfrib.cxx
@@ -249,10 +249,14 @@ void LwpFrib::RegisterStyle(LwpFoundry* pFoundry)
     XFTextStyle* pStyle = NULL;
     m_StyleName = "";
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+    XFTextStyle* pNamedStyle = nullptr;
     if (m_pModifiers->HasCharStyle)
     {
-        XFTextStyle* pNamedStyle = static_cast<XFTextStyle*>
+        pNamedStyle = static_cast<XFTextStyle*>
                                 (pFoundry->GetStyleManager()->GetStyle(m_pModifiers->CharStyleID));
+    }
+    if (pNamedStyle)
+    {
         if (m_pModifiers->FontID)
         {
             pStyle = new XFTextStyle();


More information about the Libreoffice-commits mailing list