Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Unified Diff: include/effects/SkLightingImageFilter.h

Issue 23533042: Fixed issues found by fuzzer (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/effects/SkBicubicImageFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/effects/SkLightingImageFilter.h
diff --git a/include/effects/SkLightingImageFilter.h b/include/effects/SkLightingImageFilter.h
index 07f713b0af44272f830319475c5312b339ab72f2..9c90cd949bc2f94718befdadf6d945f37dbc7c30 100644
--- a/include/effects/SkLightingImageFilter.h
+++ b/include/effects/SkLightingImageFilter.h
@@ -26,7 +26,8 @@ public:
return fX > fY ? (fX > fZ ? fX : fZ) : (fY > fZ ? fY : fZ);
}
void normalize() {
- SkScalar scale = SkScalarInvert(SkScalarSqrt(dot(*this)));
+ // Small epsilon is added to prevent division by 0.
+ SkScalar scale = SkScalarInvert(SkScalarSqrt(dot(*this)) + SK_ScalarNearlyZero);
fX = SkScalarMul(fX, scale);
fY = SkScalarMul(fY, scale);
fZ = SkScalarMul(fZ, scale);
« no previous file with comments | « no previous file | src/effects/SkBicubicImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698