diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-03-01 09:10:44 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-03-01 09:10:44 +0000 |
commit | 637c71b0325d9422bf93f6b5076b025916725134 (patch) | |
tree | 436b35611edca3316b0f08d5c8442e0b1f142606 /lotuswordpro | |
parent | 79d3c022394d6e07c1f4268f11233b9600ff4360 (diff) |
coverity#1401593 Wrapper object use after free
Change-Id: I7fdaf527ffbe7d3d952c17c62707bb4a22b05f1d
Diffstat (limited to 'lotuswordpro')
-rw-r--r-- | lotuswordpro/source/filter/lwppagelayout.cxx | 58 |
1 files changed, 27 insertions, 31 deletions
diff --git a/lotuswordpro/source/filter/lwppagelayout.cxx b/lotuswordpro/source/filter/lwppagelayout.cxx index 45e1047956c2..08566613d2f3 100644 --- a/lotuswordpro/source/filter/lwppagelayout.cxx +++ b/lotuswordpro/source/filter/lwppagelayout.cxx @@ -312,8 +312,7 @@ void LwpPageLayout::ParseFootNoteSeparator(XFPageMaster * pm1) */ void LwpPageLayout::RegisterStyle() { - std::unique_ptr<XFPageMaster> xpm1(new XFPageMaster()); - m_pXFPageMaster = xpm1.get(); + std::unique_ptr<XFPageMaster> xpm1(new XFPageMaster); ParseGeometry(xpm1.get()); //Does not process LayoutScale, for watermark is not supported in SODC. @@ -339,11 +338,11 @@ void LwpPageLayout::RegisterStyle() OUString pmname = pm1->GetStyleName(); //Add master page - XFMasterPage* p1 = new XFMasterPage; + std::unique_ptr<XFMasterPage> p1(new XFMasterPage); p1->SetStyleName(GetName().str()); p1->SetPageMaster(pmname); - p1 = static_cast<XFMasterPage*>(pXFStyleManager->AddStyle(p1).m_pStyle); - m_StyleName = p1->GetStyleName(); + XFMasterPage* p1_added = static_cast<XFMasterPage*>(pXFStyleManager->AddStyle(p1.release()).m_pStyle); + m_StyleName = p1_added->GetStyleName(); //Set footer style LwpFooterLayout* pLayoutFooter = GetFooterLayout(); @@ -351,7 +350,7 @@ void LwpPageLayout::RegisterStyle() { pLayoutFooter->SetFoundry(m_pFoundry); pLayoutFooter->RegisterStyle(pm1); - pLayoutFooter->RegisterStyle(p1); + pLayoutFooter->RegisterStyle(p1_added); } //Set header style @@ -360,7 +359,7 @@ void LwpPageLayout::RegisterStyle() { pLayoutHeader->SetFoundry(m_pFoundry); pLayoutHeader->RegisterStyle(pm1); - pLayoutHeader->RegisterStyle(p1); + pLayoutHeader->RegisterStyle(p1_added); } //register child layout style for mirror page and frame RegisterChildStyle(); @@ -372,18 +371,15 @@ void LwpPageLayout::RegisterStyle() */ OUString LwpPageLayout::RegisterEndnoteStyle() { - XFPageMaster* pm1 = new XFPageMaster(); - m_pXFPageMaster = pm1; - - ParseGeometry( pm1 ); - ParseWaterMark( pm1); - ParseMargins( pm1); - ParseColumns(pm1); - ParseBorders(pm1); - ParseShadow(pm1); -// ParseBackColor(pm1); - ParseBackGround(pm1); - //ParseFootNoteSeparator(pm1); + std::unique_ptr<XFPageMaster> pm1(new XFPageMaster); + + ParseGeometry(pm1.get()); + ParseWaterMark(pm1.get()); + ParseMargins(pm1.get()); + ParseColumns(pm1.get()); + ParseBorders(pm1.get()); + ParseShadow(pm1.get()); + ParseBackGround(pm1.get()); pm1->SetTextDir(GetTextDirection()); LwpUseWhen* pUseWhen = GetUseWhen(); @@ -394,11 +390,11 @@ OUString LwpPageLayout::RegisterEndnoteStyle() //Add the page master to stylemanager XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - m_pXFPageMaster = pm1 = static_cast<XFPageMaster*>(pXFStyleManager->AddStyle(pm1).m_pStyle); - OUString pmname = pm1->GetStyleName(); + m_pXFPageMaster = static_cast<XFPageMaster*>(pXFStyleManager->AddStyle(pm1.release()).m_pStyle); + OUString pmname = m_pXFPageMaster->GetStyleName(); //Add master page - XFMasterPage* p1 = new XFMasterPage; + std::unique_ptr<XFMasterPage> p1(new XFMasterPage); p1->SetStyleName("Endnote"); p1->SetPageMaster(pmname); @@ -407,8 +403,8 @@ OUString LwpPageLayout::RegisterEndnoteStyle() if(pLayoutFooter) { pLayoutFooter->SetFoundry(m_pFoundry); - pLayoutFooter->RegisterStyle(pm1); - pLayoutFooter->RegisterStyle(p1); + pLayoutFooter->RegisterStyle(m_pXFPageMaster); + pLayoutFooter->RegisterStyle(p1.get()); } //Set header style @@ -416,11 +412,11 @@ OUString LwpPageLayout::RegisterEndnoteStyle() if(pLayoutHeader) { pLayoutHeader->SetFoundry(m_pFoundry); - pLayoutHeader->RegisterStyle(pm1); - pLayoutHeader->RegisterStyle(p1); + pLayoutHeader->RegisterStyle(m_pXFPageMaster); + pLayoutHeader->RegisterStyle(p1.get()); } - return pXFStyleManager->AddStyle(p1).m_pStyle->GetStyleName(); + return pXFStyleManager->AddStyle(p1.release()).m_pStyle->GetStyleName(); } /** * @descr: Whether current page layout has columns @@ -754,7 +750,7 @@ void LwpHeaderLayout::Read() void LwpHeaderLayout::RegisterStyle(XFPageMaster* pm1) { - std::unique_ptr<XFHeaderStyle> xHeaderStyle(new XFHeaderStyle()); + std::unique_ptr<XFHeaderStyle> xHeaderStyle(new XFHeaderStyle); //Modify page top margin //page top marging: from top of header to the top edge @@ -872,7 +868,7 @@ void LwpHeaderLayout::ParseWaterMark(XFHeaderStyle * pHeaderStyle) void LwpHeaderLayout::RegisterStyle(XFMasterPage* mp1) { - rtl::Reference<XFHeader> xHeader(new XFHeader()); + rtl::Reference<XFHeader> xHeader(new XFHeader); rtl::Reference<LwpObject> pStory = m_Content.obj(); if(pStory.is()) { @@ -918,7 +914,7 @@ void LwpFooterLayout::Read() void LwpFooterLayout::RegisterStyle(XFPageMaster* pm1) { - std::unique_ptr<XFFooterStyle> xFooterStyle(new XFFooterStyle()); + std::unique_ptr<XFFooterStyle> xFooterStyle(new XFFooterStyle); //Modify page bottom margin //page bottom margin: from bottom of footer to the bottom edge @@ -1023,7 +1019,7 @@ void LwpFooterLayout::ParseBackColor(XFFooterStyle* pFooterStyle) void LwpFooterLayout::RegisterStyle(XFMasterPage* mp1) { - rtl::Reference<XFFooter> xFooter(new XFFooter()); + rtl::Reference<XFFooter> xFooter(new XFFooter); rtl::Reference<LwpObject> pStory = m_Content.obj(VO_STORY); //Call the RegisterStyle first to register the styles in footer paras, and then XFConvert() if(pStory.is()) |