Fix stack buffer read overflow in GrConvolutionEffect::TestCreate.
authorbungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 20 Aug 2013 15:20:34 +0000 (15:20 +0000)
committerbungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 20 Aug 2013 15:20:34 +0000 (15:20 +0000)
BUG=skia:1532
R=bsalomon@google.com, robertphillips@google.com

Review URL: https://codereview.chromium.org/23340003

git-svn-id: http://skia.googlecode.com/svn/trunk@10816 2bbb7eff-a529-9590-31e7-b0007b416f81

src/gpu/effects/GrConvolutionEffect.cpp

index aad7d4938d2353d9c61a31a707304d59aebea2a8..925a8188f6828117081ab25bc80ebb09c4e67b6a 100644 (file)
@@ -227,12 +227,12 @@ GrEffectRef* GrConvolutionEffect::TestCreate(SkMWCRandom* random,
                                       GrEffectUnitTest::kAlphaTextureIdx;
     Direction dir = random->nextBool() ? kX_Direction : kY_Direction;
     int radius = random->nextRangeU(1, kMaxKernelRadius);
-    float kernel[kMaxKernelRadius];
-    for (int i = 0; i < kMaxKernelRadius; ++i) {
+    float kernel[kMaxKernelWidth];
+    for (size_t i = 0; i < SK_ARRAY_COUNT(kernel); ++i) {
         kernel[i] = random->nextSScalar1();
     }
     float bounds[2];
-    for (int i = 0; i < 2; ++i) {
+    for (size_t i = 0; i < SK_ARRAY_COUNT(bounds); ++i) {
         bounds[i] = random->nextF();
     }