hwpfilter/source/drawing.h | 13 +++++++++---- hwpfilter/source/hwpfile.cxx | 9 +++++++-- hwpfilter/source/hwpfile.h | 2 ++ hwpfilter/source/hwpread.cxx | 2 +- 4 files changed, 19 insertions(+), 7 deletions(-)
New commits: commit eb7435503eced73869e3a1192cc613c496a06e3b Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Sun Feb 27 21:17:52 2022 +0000 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Wed Mar 2 21:00:16 2022 +0100 ofz#44991 keep paragraph's that failed to load until import is complete to avoid dangling references to them Change-Id: Ic8710f63a8cf6a6a665348c7c84bf0b43f0e2c83 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130643 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit 4836ac408b04225b66246671e29a54cd0d6703cf) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130869 Tested-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/hwpfilter/source/drawing.h b/hwpfilter/source/drawing.h index 60bd74f80f80..8d046b0e4a2d 100644 --- a/hwpfilter/source/drawing.h +++ b/hwpfilter/source/drawing.h @@ -316,7 +316,7 @@ static bool LoadCommonHeader(HWPDrawingObject * hdo, unsigned short * link_info) return hmem->skipBlock(size - common_size ) != 0; } -static std::unique_ptr<HWPDrawingObject> LoadDrawingObject(void) +static std::unique_ptr<HWPDrawingObject> LoadDrawingObject(HWPFile& hwpf) { HWPDrawingObject *prev = nullptr; std::unique_ptr<HWPDrawingObject> hdo, head; @@ -355,7 +355,7 @@ static std::unique_ptr<HWPDrawingObject> LoadDrawingObject(void) } if (link_info & HDOFILE_HAS_CHILD) { - hdo->child = LoadDrawingObject(); + hdo->child = LoadDrawingObject(hwpf); if (hdo->child == nullptr) { goto error; @@ -384,6 +384,11 @@ error: { hdo->type = HWPDO_RECT; } + if (hdo->property.pPara) + { + hwpf.move_to_failed(std::unique_ptr<HWPPara>(hdo->property.pPara)); + hdo->property.pPara = nullptr; + } HWPDOFunc(hdo.get(), OBJFUNC_FREE, nullptr, 0); hdo.reset(); @@ -397,7 +402,7 @@ error: } -static bool LoadDrawingObjectBlock(Picture * pic) +static bool LoadDrawingObjectBlock(Picture * pic, HWPFile& hwpf) { int size; if (!hmem->read4b(size)) @@ -423,7 +428,7 @@ static bool LoadDrawingObjectBlock(Picture * pic) !hmem->skipBlock(size - HDOFILE_HEADER_SIZE)) return false; - pic->picinfo.picdraw.hdo = LoadDrawingObject().release(); + pic->picinfo.picdraw.hdo = LoadDrawingObject(hwpf).release(); if (pic->picinfo.picdraw.hdo == nullptr) return false; return true; diff --git a/hwpfilter/source/hwpfile.cxx b/hwpfilter/source/hwpfile.cxx index eb0e16398252..a1303a8ee256 100644 --- a/hwpfilter/source/hwpfile.cxx +++ b/hwpfilter/source/hwpfile.cxx @@ -241,7 +241,7 @@ void HWPFile::ReadParaList(std::vector < HWPPara* > &aplist) aplist.push_back(spNode.release()); spNode.reset( new HWPPara ); } - pfailedlist.push_back(std::move(spNode)); + move_to_failed(std::move(spNode)); } void HWPFile::ReadParaList(std::vector< std::unique_ptr<HWPPara> > &aplist, unsigned char flag) @@ -275,7 +275,12 @@ void HWPFile::ReadParaList(std::vector< std::unique_ptr<HWPPara> > &aplist, unsi aplist.push_back(std::move(spNode)); spNode.reset( new HWPPara ); } - pfailedlist.push_back(std::move(spNode)); + move_to_failed(std::move(spNode)); +} + +void HWPFile::move_to_failed(std::unique_ptr<HWPPara> xPara) +{ + pfailedlist.push_back(std::move(xPara)); } void HWPFile::TagsRead() diff --git a/hwpfilter/source/hwpfile.h b/hwpfilter/source/hwpfile.h index f776460e346d..e20d6b9c48ca 100644 --- a/hwpfilter/source/hwpfile.h +++ b/hwpfilter/source/hwpfile.h @@ -257,6 +257,8 @@ class DLLEXPORT HWPFile } void pop_hpara_type() { element_import_stack.pop_back(); } + void move_to_failed(std::unique_ptr<HWPPara> rPara); + private: int compareCharShape(CharShape const *shape); int compareParaShape(ParaShape const *shape); diff --git a/hwpfilter/source/hwpread.cxx b/hwpfilter/source/hwpread.cxx index 12f29a38925e..f3a6401260c5 100644 --- a/hwpfilter/source/hwpread.cxx +++ b/hwpfilter/source/hwpread.cxx @@ -490,7 +490,7 @@ bool Picture::Read(HWPFile & hwpf) if (pictype == PICTYPE_DRAW) { auto xGuard(std::make_unique<ChangeMemGuard>(follow.data(), follow_block_size)); - LoadDrawingObjectBlock(this); + LoadDrawingObjectBlock(this, hwpf); style.cell = picinfo.picdraw.hdo; xGuard.reset(); }