summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2018-01-15 15:38:23 +0100
committerDavid Tardon <dtardon@redhat.com>2018-01-15 15:40:02 +0100
commit09e8d83be395fdb6e7540bff32107fb579004d9b (patch)
treef342c66d1777957dd8ef913fe5b0eaa6ba2c9ec6
parent13b245e648d70f9d80375887d70928ee5d590cb3 (diff)
ofz#5295 fix division by 0
Change-Id: I2df174d871ec721210988f5348ebb719cd4a100d
-rw-r--r--src/lib/FHParser.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/lib/FHParser.cpp b/src/lib/FHParser.cpp
index 1f67614..6b86f9f 100644
--- a/src/lib/FHParser.cpp
+++ b/src/lib/FHParser.cpp
@@ -1814,15 +1814,18 @@ void libfreehand::FHParser::readPolygonFigure(librevenge::RVNGInputStream *input
}
FHPath path;
- path.appendMoveTo(r1 * cos(arc1) + cx, r1 * sin(arc1) + cy);
- double deltaArc = arc2 - arc1;
- for (double arc = arc1; arc < arc1 + 2.0 * M_PI; arc += 2.0 * M_PI / numSegments)
+ if (numSegments > 0)
{
- path.appendLineTo(r1 * cos(arc) + cx, r1 * sin(arc) + cy);
- path.appendLineTo(r2 * cos(arc + deltaArc) + cx, r2 * sin(arc + deltaArc) + cy);
+ path.appendMoveTo(r1 * cos(arc1) + cx, r1 * sin(arc1) + cy);
+ double deltaArc = arc2 - arc1;
+ for (double arc = arc1; arc < arc1 + 2.0 * M_PI; arc += 2.0 * M_PI / numSegments)
+ {
+ path.appendLineTo(r1 * cos(arc) + cx, r1 * sin(arc) + cy);
+ path.appendLineTo(r2 * cos(arc + deltaArc) + cx, r2 * sin(arc + deltaArc) + cy);
+ }
+ path.appendLineTo(r1 * cos(arc1) + cx, r1 * sin(arc1) + cy);
+ path.appendClosePath();
}
- path.appendLineTo(r1 * cos(arc1) + cx, r1 * sin(arc1) + cy);
- path.appendClosePath();
input->seek(8, librevenge::RVNG_SEEK_CUR);
path.setXFormId(xform);
path.setGraphicStyleId(graphicStyle);