Revert "Fix div-by-zero loophole in gradient factory func"
This reverts commit c34dd6c5263490b94ef9af7a14dee1b4bc872b58.
Reason for revert: Speculative fix for Chrome roll (gradient layout test failures)
Original change's description:
> Fix div-by-zero loophole in gradient factory func
>
> Bug: oss-fuzz:10373
> Change-Id: I4277fb63e3186ee34feaf09ecf6aeddeb532f9c1
> Reviewed-on: https://skia-review.googlesource.com/c/168269
> Reviewed-by: Kevin Lubick <kjlubick@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
TBR=jvanverth@google.com,kjlubick@google.com,michaelludwig@google.com
Change-Id: I6333390d2ecc559ad98bd4d734ab1c674e23037f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: oss-fuzz:10373
Reviewed-on: https://skia-review.googlesource.com/c/168460
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/src/shaders/gradients/SkGradientShader.cpp b/src/shaders/gradients/SkGradientShader.cpp
index 6e0c98d..52a9b56 100644
--- a/src/shaders/gradients/SkGradientShader.cpp
+++ b/src/shaders/gradients/SkGradientShader.cpp
@@ -694,23 +694,19 @@
if (startRadius < 0 || endRadius < 0) {
return nullptr;
}
- if (SkScalarNearlyZero((start - end).length())) {
- // If the center positions are the same, then the gradient is the radial variant of a
- // 2 pt conical gradient, or an actual radial gradient (startRadius == 0), or it is
- // fully degenerate (startRadius == endRadius).
- if (SkScalarNearlyEqual(startRadius, endRadius)) {
- // Degenerate case
- return SkShader::MakeEmptyShader();
- } else if (SkScalarNearlyZero(startRadius)) {
- // We can treat this gradient as radial, which is faster.
- return MakeRadial(start, endRadius, colors, std::move(colorSpace), pos, colorCount,
- mode, flags, localMatrix);
- }
+ if (SkScalarNearlyZero((start - end).length()) && SkScalarNearlyZero(startRadius)) {
+ // We can treat this gradient as radial, which is faster.
+ return MakeRadial(start, endRadius, colors, std::move(colorSpace), pos, colorCount,
+ mode, flags, localMatrix);
}
if (!valid_grad(colors, pos, colorCount, mode)) {
return nullptr;
}
-
+ if (startRadius == endRadius) {
+ if (start == end || startRadius == 0) {
+ return SkShader::MakeEmptyShader();
+ }
+ }
if (localMatrix && !localMatrix->invert(nullptr)) {
return nullptr;
}