diff options
author | mtklein <mtklein@chromium.org> | 2015-08-13 07:51:29 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-13 07:51:29 -0700 |
commit | 15f4951e84a0aef2ed31b2e66129579feaa18850 (patch) | |
tree | b20ea877e12136318ba4d5c642bcbf5fcd722f99 /src/core/Sk4px.h | |
parent | 272b74879233e779b25bb86857b15deff3e4241b (diff) |
add asserts on Sk4px::Map functions that our arrays are non-null.
There's a crasher (null dereference it looks like) in Clank with an impossible stack, but with blit mask on top (apparently sk_free() calls blit mask...). Can't hurt to check that all these Sk4px-using methods are iterating over non-null arrays.
(This is that bug I mentioned that got me thinking about blit mask in the first place.)
BUG=520354
Review URL: https://codereview.chromium.org/1295443002
Diffstat (limited to 'src/core/Sk4px.h')
-rw-r--r-- | src/core/Sk4px.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/core/Sk4px.h b/src/core/Sk4px.h index ffde1af504..996847fa12 100644 --- a/src/core/Sk4px.h +++ b/src/core/Sk4px.h @@ -110,6 +110,8 @@ public: // fn should take an Sk4px (4 src pixels) and return an Sk4px (4 dst pixels). template <typename Fn, typename Dst> static void MapSrc(int n, Dst* dst, const SkPMColor* src, const Fn& fn) { + SkASSERT(dst); + SkASSERT(src); // This looks a bit odd, but it helps loop-invariant hoisting across different calls to fn. // Basically, we need to make sure we keep things inside a single loop. while (n > 0) { @@ -140,6 +142,8 @@ public: // As above, but with dst4' = fn(dst4, src4). template <typename Fn, typename Dst> static void MapDstSrc(int n, Dst* dst, const SkPMColor* src, const Fn& fn) { + SkASSERT(dst); + SkASSERT(src); while (n > 0) { if (n >= 8) { Sk4px dst0 = fn(Load4(dst+0), Load4(src+0)), @@ -168,6 +172,8 @@ public: // As above, but with dst4' = fn(dst4, alpha4). template <typename Fn, typename Dst> static void MapDstAlpha(int n, Dst* dst, const SkAlpha* a, const Fn& fn) { + SkASSERT(dst); + SkASSERT(a); while (n > 0) { if (n >= 8) { Sk4px dst0 = fn(Load4(dst+0), Load4Alphas(a+0)), @@ -197,6 +203,9 @@ public: template <typename Fn, typename Dst> static void MapDstSrcAlpha(int n, Dst* dst, const SkPMColor* src, const SkAlpha* a, const Fn& fn) { + SkASSERT(dst); + SkASSERT(src); + SkASSERT(a); while (n > 0) { if (n >= 8) { Sk4px dst0 = fn(Load4(dst+0), Load4(src+0), Load4Alphas(a+0)), |