Adding 64 bit checks
authorsugoi <sugoi@chromium.org>
Thu, 3 Jul 2014 17:44:26 +0000 (10:44 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 3 Jul 2014 17:44:26 +0000 (10:44 -0700)
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

src/core/SkConvolver.cpp
src/core/SkScaledImageCache.cpp
src/effects/SkColorMatrixFilter.cpp

index 4633c2e2eab970de5372d07ce4ea5c1c1ecc587f..23a1ee3aaf7d9faf498ad41004ee8a3ada514540 100644 (file)
@@ -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;
index f266f97171533f3c3a66978f6a300520f3e085af..a030248197a391787c62e0b46f96fb9f199202a2 100644 (file)
@@ -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;
     }
 
index b60fa84b68d454de73e0ab17330e6d0bfebe7724..bd1df79d14f6ede472742c0544755b027f12d755 100644 (file)
@@ -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);