Index: src/pathops/SkPathOpsCubic.cpp |
diff --git a/src/pathops/SkPathOpsCubic.cpp b/src/pathops/SkPathOpsCubic.cpp |
index 6b74fb00efac83990703727eb207997f3460c467..a161e368e7da5e44a17d7a47741aefc98841a7ee 100644 |
--- a/src/pathops/SkPathOpsCubic.cpp |
+++ b/src/pathops/SkPathOpsCubic.cpp |
@@ -419,7 +419,8 @@ int SkDCubic::RootsReal(double A, double B, double C, double D, double s[3]) { |
double r; |
double* roots = s; |
if (R2MinusQ3 < 0) { // we have 3 real roots |
- double theta = acos(R / sqrt(Q3)); |
+ // the divide/root can, due to finite precisions, be slightly outside of -1...1 |
+ double theta = acos(SkTPin(R / sqrt(Q3), -1., 1.)); |
double neg2RootQ = -2 * sqrt(Q); |
r = neg2RootQ * cos(theta / 3) - adiv3; |