office-gobmx/external/libodfgen/ellipticalarc.patch
Stephan Bergmann fa75935958 external/libodfgen: Avoid division by zero for empty elliptical arc
...as seen when running under UBSan `instdir/program/soffice --headless
--convert-to epub` of caolan/libmspub_icu_global_buffer_overflow.sample from the
crash-testing corpus.

<https://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes> specifies:
"If the endpoints (x1, y1) and (x2, y2) are identical, then this is equivalent
to omitting the elliptical arc segment entirely."  (And getEllipticalArgBox's
xmin, ymin, xmax, and ymax out parameters are pre-filled with suitable values at
the call site in getPathBBox, so that we can return here without setting those
out parameters.)

Change-Id: I6b0b693354648f4015cec2395737fb9abe5ae956
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119680
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-08-01 17:20:17 +02:00

13 lines
366 B
Diff

--- src/GraphicFunctions.cxx
+++ src/GraphicFunctions.cxx
@@ -59,6 +59,10 @@
double rx, double ry, double phi, bool largeArc, bool sweep, double x, double y,
double &xmin, double &ymin, double &xmax, double &ymax)
{
+ if (x0 == x && y0 == y) {
+ return;
+ }
+
phi *= M_PI/180;
if (rx < 0.0)
rx *= -1.0;