Kaydet (Commit) b6f2b0ad authored tarafından Caolán McNamara's avatar Caolán McNamara Kaydeden (comit) Andras Timar

coverity#1343623 Logically dead code

(cherry picked from commit 8f3c796e)

coverity#1343624 Unchecked dynamic_cast

(cherry picked from commit 26fddc31)

coverity#1343625 Unchecked dynamic_cast

(cherry picked from commit 9e83e310)

coverity#1343626 Unchecked dynamic_cast

(cherry picked from commit c2f17316)

coverity#1343627 Unchecked dynamic_cast

(cherry picked from commit 1276f6da)

coverity#1343629 Unchecked dynamic_cast

(cherry picked from commit 274d265e)

1343630 Dereference after null check

(cherry picked from commit 960cfb7e)
(cherry picked from commit 7e6e8aa8)

Change-Id: Ibcf05263f7bea50f70d55f4d8944d0a41d54851d
a303a5dc97fb5e491e86a3484040e657f1b480d4
b534e4e8ecf50a9159c5e98e2c899bf13f44c654
52e6d6c9cb48880185293fb9825d7a6530ee767d
83c0febcbbf0f19a05818e0575921d1d6254935f
93b7298d785e57a4ef854cea3e9cd5c2c0f35849
81223b868f069755e8a46c57bfe0282021f26de7
Reviewed-on: https://gerrit.libreoffice.org/20832Reviewed-by: 's avatarDavid Tardon <dtardon@redhat.com>
Tested-by: 's avatarDavid Tardon <dtardon@redhat.com>

(cherry picked from commit b8b7669d)
üst 743fc27c
...@@ -257,11 +257,13 @@ void LwpFrib::RegisterStyle(LwpFoundry* pFoundry) ...@@ -257,11 +257,13 @@ void LwpFrib::RegisterStyle(LwpFoundry* pFoundry)
} }
if (pNamedStyle) if (pNamedStyle)
{ {
LwpCharacterStyle* pCharStyle = nullptr;
if (m_pModifiers->FontID && pFoundry) if (m_pModifiers->FontID && pFoundry)
pCharStyle = dynamic_cast<LwpCharacterStyle*>(m_pModifiers->CharStyleID.obj().get());
if (pCharStyle)
{ {
pStyle = new XFTextStyle(); pStyle = new XFTextStyle();
*pStyle = *pNamedStyle; *pStyle = *pNamedStyle;
LwpCharacterStyle* pCharStyle = dynamic_cast<LwpCharacterStyle*>(m_pModifiers->CharStyleID.obj().get());
pStyle->SetStyleName(""); pStyle->SetStyleName("");
pFont = pFoundry->GetFontManger().CreateOverrideFont(pCharStyle->GetFinalFontID(),m_pModifiers->FontID); pFont = pFoundry->GetFontManger().CreateOverrideFont(pCharStyle->GetFinalFontID(),m_pModifiers->FontID);
......
...@@ -193,7 +193,7 @@ void LwpFribSection::SetDefaultAlphaIndex(XFIndex * pXFIndex) ...@@ -193,7 +193,7 @@ void LwpFribSection::SetDefaultAlphaIndex(XFIndex * pXFIndex)
LwpIndexSection* pIndexSection = dynamic_cast<LwpIndexSection*>(m_Section.obj().get()); LwpIndexSection* pIndexSection = dynamic_cast<LwpIndexSection*>(m_Section.obj().get());
XFIndexTemplate * pTemplateSep = new XFIndexTemplate(); XFIndexTemplate * pTemplateSep = new XFIndexTemplate();
if (pIndexSection->IsFormatSeparator()) if (pIndexSection && pIndexSection->IsFormatSeparator())
{ {
pXFIndex->SetSeparator(true); pXFIndex->SetSeparator(true);
pTemplateSep->AddEntry(enumXFIndexTemplateText,""); pTemplateSep->AddEntry(enumXFIndexTemplateText,"");
...@@ -219,7 +219,7 @@ void LwpFribSection::SetDefaultAlphaIndex(XFIndex * pXFIndex) ...@@ -219,7 +219,7 @@ void LwpFribSection::SetDefaultAlphaIndex(XFIndex * pXFIndex)
pTemplate3->AddEntry(enumXFIndexTemplateTab,""); pTemplate3->AddEntry(enumXFIndexTemplateTab,"");
pTemplate3->AddEntry(enumXFIndexTemplatePage,""); pTemplate3->AddEntry(enumXFIndexTemplatePage,"");
if (pIndexSection->IsFormatRunin()) if (pIndexSection && pIndexSection->IsFormatRunin())
{ {
//pXFIndex->AddTemplate(OUString::number(2),"Primary",pTemplate2); //pXFIndex->AddTemplate(OUString::number(2),"Primary",pTemplate2);
//pXFIndex->AddTemplate(OUString::number(3),"Primary",pTemplate3); //pXFIndex->AddTemplate(OUString::number(3),"Primary",pTemplate3);
...@@ -247,10 +247,13 @@ LwpMasterPage::LwpMasterPage(LwpPara* pPara, LwpPageLayout* pLayout) ...@@ -247,10 +247,13 @@ LwpMasterPage::LwpMasterPage(LwpPara* pPara, LwpPageLayout* pLayout)
*/ */
bool LwpMasterPage::RegisterMasterPage(LwpFrib* pFrib) bool LwpMasterPage::RegisterMasterPage(LwpFrib* pFrib)
{ {
//if there is no other frib after current firb, register master page in starting para of next page //if there is no other frib after current frib, register master page in starting para of next page
if(IsNextPageType()&&(!pFrib->HasNextFrib())) LwpStory* pStory = nullptr;
if (IsNextPageType()&&(!pFrib->HasNextFrib()))
pStory = dynamic_cast<LwpStory*>(m_pPara->GetStoryID().obj().get());
if (pStory)
{ {
LwpStory* pStory = dynamic_cast<LwpStory*>(m_pPara->GetStoryID().obj().get());
pStory->SetCurrentLayout(m_pLayout); pStory->SetCurrentLayout(m_pLayout);
RegisterFillerPageStyle(); RegisterFillerPageStyle();
return false; return false;
...@@ -281,7 +284,9 @@ bool LwpMasterPage::RegisterMasterPage(LwpFrib* pFrib) ...@@ -281,7 +284,9 @@ bool LwpMasterPage::RegisterMasterPage(LwpFrib* pFrib)
case LwpLayout::StartOnOddPage: //fall through case LwpLayout::StartOnOddPage: //fall through
case LwpLayout::StartOnEvenPage: case LwpLayout::StartOnEvenPage:
{ {
LwpStory* pStory = dynamic_cast<LwpStory*>(m_pPara->GetStoryID().obj().get()); pStory = dynamic_cast<LwpStory*>(m_pPara->GetStoryID().obj().get());
if (pStory)
{
pStory->SetCurrentLayout(m_pLayout); pStory->SetCurrentLayout(m_pLayout);
//get odd page layout when the current pagelayout is mirror //get odd page layout when the current pagelayout is mirror
m_pLayout = pStory->GetCurrentLayout(); m_pLayout = pStory->GetCurrentLayout();
...@@ -289,6 +294,7 @@ bool LwpMasterPage::RegisterMasterPage(LwpFrib* pFrib) ...@@ -289,6 +294,7 @@ bool LwpMasterPage::RegisterMasterPage(LwpFrib* pFrib)
//bSectionColumns = m_bNewSection; //bSectionColumns = m_bNewSection;
pOverStyle->SetMasterPage( m_pLayout->GetStyleName()); pOverStyle->SetMasterPage( m_pLayout->GetStyleName());
RegisterFillerPageStyle(); RegisterFillerPageStyle();
}
break; break;
} }
default: default:
...@@ -296,7 +302,10 @@ bool LwpMasterPage::RegisterMasterPage(LwpFrib* pFrib) ...@@ -296,7 +302,10 @@ bool LwpMasterPage::RegisterMasterPage(LwpFrib* pFrib)
} }
//register tab style; //register tab style;
LwpStory* pStory = dynamic_cast<LwpStory*>(m_pPara->GetStoryID().obj().get()); pStory = dynamic_cast<LwpStory*>(m_pPara->GetStoryID().obj().get());
if (!pStory)
return false;
pStory->SetTabLayout(m_pLayout); pStory->SetTabLayout(m_pLayout);
m_pPara->RegisterTabStyle(pOverStyle); m_pPara->RegisterTabStyle(pOverStyle);
...@@ -308,7 +317,7 @@ bool LwpMasterPage::RegisterMasterPage(LwpFrib* pFrib) ...@@ -308,7 +317,7 @@ bool LwpMasterPage::RegisterMasterPage(LwpFrib* pFrib)
XFSectionStyle* pSectStyle= new XFSectionStyle(); XFSectionStyle* pSectStyle= new XFSectionStyle();
//set margin //set margin
pStory = dynamic_cast<LwpStory*>(m_pPara->GetStoryID().obj().get()); pStory = dynamic_cast<LwpStory*>(m_pPara->GetStoryID().obj().get());
if(pStory) if (pStory)
{ {
LwpPageLayout* pCurrentLayout = pStory->GetCurrentLayout(); LwpPageLayout* pCurrentLayout = pStory->GetCurrentLayout();
double fLeft = m_pLayout->GetMarginsValue(MARGIN_LEFT)- pCurrentLayout->GetMarginsValue(MARGIN_LEFT); double fLeft = m_pLayout->GetMarginsValue(MARGIN_LEFT)- pCurrentLayout->GetMarginsValue(MARGIN_LEFT);
...@@ -341,7 +350,7 @@ bool LwpMasterPage::IsNeedSection() ...@@ -341,7 +350,7 @@ bool LwpMasterPage::IsNeedSection()
//get story //get story
LwpStory* pStory = dynamic_cast<LwpStory*>(m_pPara->GetStoryID().obj().get()); LwpStory* pStory = dynamic_cast<LwpStory*>(m_pPara->GetStoryID().obj().get());
//if pagelayout is modified, register the pagelayout //if pagelayout is modified, register the pagelayout
if(pStory->IsPMModified()) if (pStory && pStory->IsPMModified())
{ {
bNewSection = pStory->IsNeedSection(); bNewSection = pStory->IsNeedSection();
} }
...@@ -398,13 +407,13 @@ void LwpMasterPage::ParseSection(LwpFrib* pFrib) ...@@ -398,13 +407,13 @@ void LwpMasterPage::ParseSection(LwpFrib* pFrib)
pCurrContainer->RemoveLastContent(); pCurrContainer->RemoveLastContent();
} }
} }
//end,06/28/2005 if (pStory)
pStory->AddXFContent( pContent ); pStory->AddXFContent( pContent );
} }
else else
{ {
LwpStory* pStory = dynamic_cast<LwpStory*> ( m_pPara->GetStoryID().obj().get() ); LwpStory* pStory = dynamic_cast<LwpStory*> ( m_pPara->GetStoryID().obj().get() );
pContent = pStory->GetXFContent(); pContent = pStory ? pStory->GetXFContent() : nullptr;
} }
if(pContent) if(pContent)
{ {
......
...@@ -311,7 +311,7 @@ void LwpPara::XFConvert(XFContentContainer* pCont) ...@@ -311,7 +311,7 @@ void LwpPara::XFConvert(XFContentContainer* pCont)
m_Fribs.SetXFPara(pPara); m_Fribs.SetXFPara(pPara);
m_Fribs.XFConvert(); m_Fribs.XFConvert();
if (m_pBreaks) if (m_pBreaks && m_pXFContainer)
AddBreakAfter(m_pXFContainer); AddBreakAfter(m_pXFContainer);
} }
......
...@@ -100,7 +100,7 @@ void XFCell::Add(XFContent *pContent) ...@@ -100,7 +100,7 @@ void XFCell::Add(XFContent *pContent)
} }
if( pContent->GetContentType() == enumXFContentTable ) if( pContent->GetContentType() == enumXFContentTable )
{ {
XFTable *pTable = static_cast<XFTable*>(pContent); XFTable *pTable = dynamic_cast<XFTable*>(pContent);
if( !pTable ) if( !pTable )
return; return;
//the sub table will fill all the cell, there can't be other contents. //the sub table will fill all the cell, there can't be other contents.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment