diff options
author | 2014-07-03 10:44:26 -0700 | |
---|---|---|
committer | 2014-07-03 10:44:26 -0700 | |
commit | c197c8a47eb9cf09b389f4dd5d235510feec18cb (patch) | |
tree | 4fe97a698b9b9aab382d1615910e5df4808dd7af | |
parent | 2fe7b466c15fab6593da3bf32d3c3dbdf3917c01 (diff) |
Adding 64 bit checks
Added a few more checks to avoid overflowing 32 bit sizes while computing convolutions.
I also changed a dangerously misleading INHERITED typedef.
BUG=389570
R=senorblanco@google.com, senorblanco@chromium.org
Author: sugoi@chromium.org
Review URL: https://codereview.chromium.org/361403006
-rw-r--r-- | src/core/SkConvolver.cpp | 2 | ||||
-rw-r--r-- | src/core/SkScaledImageCache.cpp | 3 | ||||
-rw-r--r-- | src/effects/SkColorMatrixFilter.cpp | 4 |
3 files changed, 6 insertions, 3 deletions
diff --git a/src/core/SkConvolver.cpp b/src/core/SkConvolver.cpp index 4633c2e2ea..23a1ee3aaf 100644 --- a/src/core/SkConvolver.cpp +++ b/src/core/SkConvolver.cpp @@ -459,7 +459,7 @@ void BGRAConvolve2D(const unsigned char* sourceData, } // Compute where in the output image this row of final data will go. - unsigned char* curOutputRow = &output[outY * outputByteRowStride]; + unsigned char* curOutputRow = &output[(uint64_t)outY * outputByteRowStride]; // Get the list of rows that the circular buffer has, in order. int firstRowInCircularBuffer; diff --git a/src/core/SkScaledImageCache.cpp b/src/core/SkScaledImageCache.cpp index f266f97171..a030248197 100644 --- a/src/core/SkScaledImageCache.cpp +++ b/src/core/SkScaledImageCache.cpp @@ -266,7 +266,8 @@ private: bool SkScaledImageCacheDiscardableAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTable* ctable) { size_t size = bitmap->getSize(); - if (0 == size) { + uint64_t size64 = bitmap->computeSize64(); + if (0 == size || size64 > (uint64_t)size) { return false; } diff --git a/src/effects/SkColorMatrixFilter.cpp b/src/effects/SkColorMatrixFilter.cpp index b60fa84b68..bd1df79d14 100644 --- a/src/effects/SkColorMatrixFilter.cpp +++ b/src/effects/SkColorMatrixFilter.cpp @@ -450,6 +450,8 @@ public: private: GrGLUniformManager::UniformHandle fMatrixHandle; GrGLUniformManager::UniformHandle fVectorHandle; + + typedef GrGLEffect INHERITED; }; private: @@ -462,7 +464,7 @@ private: SkColorMatrix fMatrix; - typedef GrGLEffect INHERITED; + typedef GrEffect INHERITED; }; GR_DEFINE_EFFECT_TEST(ColorMatrixEffect); |