diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-06-26 19:26:40 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2021-06-30 09:53:16 +0200 |
commit | efdc0f7eebec5effa06475282b98f56d56f97537 (patch) | |
tree | f23fbece5b194b49cb355bf950be85ce04639620 /oox | |
parent | b971352b475cdc1e97300a2c052859d1a2742668 (diff) |
ofz#35597 Null-dereference READ
add a check for null getTextBody() return
unfold it a bit while I'm at it
Change-Id: Ib0286048536ad576b520e1adb08fa9b36da9243f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117938
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
(cherry picked from commit 00a658ff104623d4e7fc984b5fc82d1a7e2607f2)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117871
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/ppt/pptshape.cxx | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx index 5f21f7c459c9..7e294f197fe1 100644 --- a/oox/source/ppt/pptshape.cxx +++ b/oox/source/ppt/pptshape.cxx @@ -90,7 +90,7 @@ static const char* lclDebugSubType( sal_Int32 nType ) namespace { -bool ShapeHasNoVisualPropertiesOnImport(oox::ppt::PPTShape& rPPTShape) +bool ShapeHasNoVisualPropertiesOnImport(const oox::ppt::PPTShape& rPPTShape) { return !rPPTShape.hasNonInheritedShapeProperties() && !rPPTShape.hasShapeStyleRefs() @@ -126,6 +126,23 @@ oox::drawingml::TextListStylePtr PPTShape::getSubTypeTextListStyle( const SlideP return pTextListStyle; } +bool PPTShape::IsPlaceHolderCandidate(const SlidePersist& rSlidePersist) const +{ + if (meShapeLocation != Slide) + return false; + if (rSlidePersist.isNotesPage()) + return false; + auto pTextBody = getTextBody(); + if (!pTextBody) + return false; + auto rParagraphs = pTextBody->getParagraphs(); + if (rParagraphs.size() != 1) + return false; + if (rParagraphs.front()->getRuns().size() != 1) + return false; + return ShapeHasNoVisualPropertiesOnImport(*this); +} + void PPTShape::addShape( oox::core::XmlFilterBase& rFilterBase, const SlidePersist& rSlidePersist, @@ -193,10 +210,7 @@ void PPTShape::addShape( } break; case XML_dt : - if ( meShapeLocation == Slide && !rSlidePersist.isNotesPage() - && getTextBody()->getParagraphs().size() == 1 - && getTextBody()->getParagraphs().front()->getRuns().size() == 1 - && ShapeHasNoVisualPropertiesOnImport(*this) ) + if (IsPlaceHolderCandidate(rSlidePersist)) { TextRunPtr& pTextRun = getTextBody()->getParagraphs().front()->getRuns().front(); oox::drawingml::TextField* pTextField = dynamic_cast<oox::drawingml::TextField*>(pTextRun.get()); @@ -232,10 +246,7 @@ void PPTShape::addShape( bClearText = true; break; case XML_ftr : - if ( meShapeLocation == Slide && !rSlidePersist.isNotesPage() - && getTextBody()->getParagraphs().size() == 1 - && getTextBody()->getParagraphs().front()->getRuns().size() == 1 - && ShapeHasNoVisualPropertiesOnImport(*this) ) + if (IsPlaceHolderCandidate(rSlidePersist)) { const OUString& rFooterText = getTextBody()->toString(); @@ -253,10 +264,7 @@ void PPTShape::addShape( bClearText = true; break; case XML_sldNum : - if (meShapeLocation == Slide && !rSlidePersist.isNotesPage() - && getTextBody()->getParagraphs().size() == 1 - && getTextBody()->getParagraphs().front()->getRuns().size() == 1 - && ShapeHasNoVisualPropertiesOnImport(*this)) + if (IsPlaceHolderCandidate(rSlidePersist)) { TextRunPtr& pTextRun = getTextBody()->getParagraphs().front()->getRuns().front(); |