hwpfilter/source/hinfo.cxx | 19 +++++++++++++------ hwpfilter/source/hinfo.h | 6 +++--- hwpfilter/source/hwpfile.cxx | 12 ++++++------ hwpfilter/source/hwpreader.cxx | 6 +++--- 4 files changed, 25 insertions(+), 18 deletions(-)
New commits: commit 43ae4e9a694c68101a907b0d1e31b4bd57e11bd1 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Mon Jun 20 10:29:00 2022 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Mon Jun 20 13:13:17 2022 +0200 ofz#47463 OOM only first byte of 'font', 'ratio' and 'space' are used 1.098GB -> 854.6MB Change-Id: I3390c3a5abe457f8d0ad49b03b50a2d353566c2a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136142 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/hwpfilter/source/hinfo.cxx b/hwpfilter/source/hinfo.cxx index 505936b92aae..9a4eb628b015 100644 --- a/hwpfilter/source/hinfo.cxx +++ b/hwpfilter/source/hinfo.cxx @@ -261,10 +261,10 @@ void ParaShape::Read(HWPFile & hwpf) CharShape::CharShape() : index(0) , size(0) - , font{0} - , ratio{0} - , space{0} , color{0} + , font(0) + , space(0) + , ratio(0) , shade(0) , attr(0) { @@ -276,9 +276,16 @@ void CharShape::Read(HWPFile & hwpf) if (!hwpf.Read2b(tmp16)) return; size = tmp16; - hwpf.ReadBlock(font, NLanguage); - hwpf.ReadBlock(ratio, NLanguage); - hwpf.ReadBlock(space, NLanguage); + + hwpf.Read1b(font); + hwpf.SkipBlock(NLanguage - 1); //skip unused part of remaining font field + + hwpf.Read1b(ratio); + hwpf.SkipBlock(NLanguage - 1); //skip unused part of remaining ratio field + + hwpf.Read1b(space); + hwpf.SkipBlock(NLanguage - 1); //skip unused part of remaining space field + hwpf.ReadBlock(color, 2); hwpf.Read1b(shade); hwpf.Read1b(attr); diff --git a/hwpfilter/source/hinfo.h b/hwpfilter/source/hinfo.h index 003dafc0d308..fe473f4effc4 100644 --- a/hwpfilter/source/hinfo.h +++ b/hwpfilter/source/hinfo.h @@ -219,10 +219,10 @@ struct CharShape * Font size */ hunit size; - unsigned char font[NLanguage]; - unsigned char ratio[NLanguage]; - signed char space[NLanguage]; /* 자간 */ unsigned char color[2]; + unsigned char font; + char space; /* 자간 */ + unsigned char ratio; unsigned char shade; unsigned char attr; diff --git a/hwpfilter/source/hwpfile.cxx b/hwpfilter/source/hwpfile.cxx index 58d6c4849d91..f9d5b3ab6008 100644 --- a/hwpfilter/source/hwpfile.cxx +++ b/hwpfilter/source/hwpfile.cxx @@ -603,9 +603,9 @@ int HWPFile::compareCharShape(CharShape const *shape) CharShape *cshape = getCharShape(i); if( shape->size == cshape->size && - shape->font[0] == cshape->font[0] && - shape->ratio[0] == cshape->ratio[0] && - shape->space[0] == cshape->space[0] && + shape->font == cshape->font && + shape->ratio == cshape->ratio && + shape->space == cshape->space && shape->color[1] == cshape->color[1] && shape->color[0] == cshape->color[0] && shape->shade == cshape->shade && @@ -639,9 +639,9 @@ int HWPFile::compareParaShape(const ParaShape* shape) shape->pagebreak == pshape->pagebreak) { if (shape->cshape->size == pshape->cshape->size && - shape->cshape->font[0] == pshape->cshape->font[0] && - shape->cshape->ratio[0] == pshape->cshape->ratio[0] && - shape->cshape->space[0] == pshape->cshape->space[0] && + shape->cshape->font == pshape->cshape->font && + shape->cshape->ratio == pshape->cshape->ratio && + shape->cshape->space == pshape->cshape->space && shape->cshape->color[1] == pshape->cshape->color[1] && shape->cshape->color[0] == pshape->cshape->color[0] && shape->cshape->shade == pshape->cshape->shade && diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx index 87c2e6412bd5..05079365b3b3 100644 --- a/hwpfilter/source/hwpreader.cxx +++ b/hwpfilter/source/hwpreader.cxx @@ -1271,7 +1271,7 @@ void HwpReader::parseCharShape(CharShape const * cshape) mxList->addAttribute("style:font-size-asian", sXML_CDATA, OUString::number(cshape->size / 25) + "pt"); ::std::string const tmp = hstr2ksstr(kstr2hstr( - reinterpret_cast<unsigned char const *>(hwpfont.GetFontName(0, cshape->font[0]))).c_str()); + reinterpret_cast<unsigned char const *>(hwpfont.GetFontName(0, cshape->font))).c_str()); double fRatio = 1.0; int size = getRepFamilyName(tmp.c_str(), d->buf, fRatio); @@ -1281,9 +1281,9 @@ void HwpReader::parseCharShape(CharShape const * cshape) OUString(d->buf, size, RTL_TEXTENCODING_EUC_KR)); mxList->addAttribute("style:text-scale", sXML_CDATA, - OUString::number(static_cast<int>(cshape->ratio[0] * fRatio)) + "%"); + OUString::number(static_cast<int>(cshape->ratio * fRatio)) + "%"); - double sspace = (cshape->size / 25) * cshape->space[0] / 100.; + double sspace = (cshape->size / 25) * cshape->space / 100.; if (sspace != 0.) {