diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-03-05 14:05:54 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-03-05 21:42:20 +0100 |
commit | 94e8b4b6a5ca957e1426f47cda898f175932183c (patch) | |
tree | 7e58e4618d752fd545921c3a9a8a9dbc725237eb | |
parent | 8030b9cf1c55cbbf9be8bf0cee0a408ff0a14710 (diff) |
ofz#45167 Integer-overflow
Change-Id: Ib112686b192558421419a8695db9c3f35c5312da
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131058
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | hwpfilter/source/hwpreader.cxx | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx index ff551174219f..a20d71b5c5c3 100644 --- a/hwpfilter/source/hwpreader.cxx +++ b/hwpfilter/source/hwpreader.cxx @@ -4054,22 +4054,26 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox) mxList->addAttribute("svg:height", sXML_CDATA, OUString::number (WTMM( drawobj->extent.h )) + "mm"); if( drawobj->type == HWPDO_ADVANCED_ELLIPSE ){ - if( drawobj->u.arc.radial[0].x != drawobj->u.arc.radial[1].x - || drawobj->u.arc.radial[0].y != drawobj->u.arc.radial[1].y ){ - int Cx,Cy; - Cx = ( drawobj->offset2.x + drawobj->extent.w ) / 2; - Cy = ( drawobj->offset2.y + drawobj->extent.h ) / 2; - - double start_angle, end_angle; - start_angle = calcAngle( Cx, Cy, drawobj->u.arc.radial[0].x, drawobj->u.arc.radial[0].y ); - end_angle = calcAngle( Cx, Cy, drawobj->u.arc.radial[1].x, drawobj->u.arc.radial[1].y ); - if( drawobj->property.fill_color < 0xffffff ) - mxList->addAttribute("draw:kind", sXML_CDATA, "section"); - else - mxList->addAttribute("draw:kind", sXML_CDATA, "arc"); - mxList->addAttribute("draw:start-angle", sXML_CDATA, OUString::number(start_angle )); - mxList->addAttribute("draw:end-angle", sXML_CDATA, OUString::number(end_angle)); - } + if (drawobj->u.arc.radial[0].x != drawobj->u.arc.radial[1].x || + drawobj->u.arc.radial[0].y != drawobj->u.arc.radial[1].y) { + + int Cx, Cy; + if (!o3tl::checked_add(drawobj->offset2.x, drawobj->extent.w, Cx) && + !o3tl::checked_add(drawobj->offset2.y, drawobj->extent.h, Cy)) + { + Cx /= 2; + Cy /= 2; + + double start_angle = calcAngle( Cx, Cy, drawobj->u.arc.radial[0].x, drawobj->u.arc.radial[0].y ); + double end_angle = calcAngle( Cx, Cy, drawobj->u.arc.radial[1].x, drawobj->u.arc.radial[1].y ); + if( drawobj->property.fill_color < 0xffffff ) + mxList->addAttribute("draw:kind", sXML_CDATA, "section"); + else + mxList->addAttribute("draw:kind", sXML_CDATA, "arc"); + mxList->addAttribute("draw:start-angle", sXML_CDATA, OUString::number(start_angle )); + mxList->addAttribute("draw:end-angle", sXML_CDATA, OUString::number(end_angle)); + } + } } startEl("draw:ellipse"); mxList->clear(); |