diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-03-14 08:54:53 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-03-14 11:37:36 +0100 |
commit | c9a4c8a8ab9933949e14de09e80333a0de6612c5 (patch) | |
tree | 2fb65ec6b8606ad9bb5c89a04ea0564d59405955 | |
parent | f34adef94825244b9834905f7cffb96505de5d2d (diff) |
ofz#45525 Null-dereference READ
Change-Id: I9d31b89fc7fa9447823ded4f6891b47100215c0a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131523
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | hwpfilter/source/hbox.h | 4 | ||||
-rw-r--r-- | hwpfilter/source/hwpreader.cxx | 8 |
2 files changed, 8 insertions, 4 deletions
diff --git a/hwpfilter/source/hbox.h b/hwpfilter/source/hbox.h index b3bdffa74911..f7813b225dd5 100644 --- a/hwpfilter/source/hbox.h +++ b/hwpfilter/source/hbox.h @@ -361,7 +361,9 @@ struct TxtBox: public FBox /** * Paragraph list */ - std::vector<std::vector<std::unique_ptr<HWPPara>>> plists; + typedef std::vector<std::unique_ptr<HWPPara>> plist_t; + typedef std::vector<plist_t> plists_t; + plists_t plists; /** * Caption diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx index 6c757409e8dc..5d364586310a 100644 --- a/hwpfilter/source/hwpreader.cxx +++ b/hwpfilter/source/hwpreader.cxx @@ -3399,7 +3399,9 @@ void HwpReader::makeTable(TxtBox * hbox) mxList->addAttribute("table:protected", sXML_CDATA,"true"); startEl("table:table-cell"); mxList->clear(); - parsePara(hbox->plists[tcell->pCell->key].front().get()); + TxtBox::plist_t& rVec = hbox->plists[tcell->pCell->key]; + if (!rVec.empty()) + parsePara(rVec.front().get()); endEl("table:table-cell"); } endEl("table:table-row"); @@ -3513,7 +3515,7 @@ void HwpReader::makeTextBox(TxtBox * hbox) startEl("draw:text-box"); mxList->clear(); /* If captions are present and it is on the top */ - if( hbox->style.cap_len > 0 && (hbox->cap_pos % 2) && hbox->type == TBL_TYPE ) + if (hbox->style.cap_len > 0 && (hbox->cap_pos % 2) && hbox->type == TBL_TYPE && !hbox->caption.empty()) { parsePara(hbox->caption.front().get()); } @@ -3526,7 +3528,7 @@ void HwpReader::makeTextBox(TxtBox * hbox) parsePara(hbox->plists[0].front().get()); } /* If captions are present and it is on the bottom */ - if( hbox->style.cap_len > 0 && !(hbox->cap_pos % 2) && hbox->type == TBL_TYPE) + if (hbox->style.cap_len > 0 && !(hbox->cap_pos % 2) && hbox->type == TBL_TYPE && !hbox->caption.empty()) { parsePara(hbox->caption.front().get()); } |