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

Unified Diff: src/core/SkAnalyticEdge.cpp

Issue 2482863004: Check negative overflow of quickSkFDot6Div (Closed)
Patch Set: Created 4 years, 1 month 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkAnalyticEdge.cpp
diff --git a/src/core/SkAnalyticEdge.cpp b/src/core/SkAnalyticEdge.cpp
index fde37e09db76014789c67cc3e9b7279847ee67f3..c17426d1db50e31668820ccebc2fc889dd112de1 100644
--- a/src/core/SkAnalyticEdge.cpp
+++ b/src/core/SkAnalyticEdge.cpp
@@ -22,8 +22,11 @@ public:
};
static inline SkFixed quickSkFDot6Div(SkFDot6 a, SkFDot6 b) {
- if (SkAbs32(b) < kInverseTableSize) {
- SkASSERT((int64_t)a * QuickFDot6Inverse::Lookup(b) <= SK_MaxS32);
+ // Max inverse of b is 2^6 which is 2^22 in SkFixed format.
+ // Hence the safe value of abs(a) should be less than 2^10.
+ if (SkAbs32(b) < kInverseTableSize && SkAbs32(a) < (1 << 10)) {
+ SkASSERT((int64_t)a * QuickFDot6Inverse::Lookup(b) <= SK_MaxS32
+ && (int64_t)a * QuickFDot6Inverse::Lookup(b) >= SK_MinS32);
SkFixed ourAnswer = (a * QuickFDot6Inverse::Lookup(b)) >> 6;
#ifdef SK_DEBUG
SkFixed directAnswer = SkFDot6Div(a, b);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698