Fix minor valgrind-found memory leaks
authorrobertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 21 Mar 2013 17:38:49 +0000 (17:38 +0000)
committerrobertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 21 Mar 2013 17:38:49 +0000 (17:38 +0000)
https://codereview.chromium.org/12440066/

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

src/core/SkRefDict.cpp
src/effects/SkMatrixConvolutionImageFilter.cpp
tests/Matrix44Test.cpp
tests/PDFPrimitivesTest.cpp

index 50a469dfc758aa1694c858a547eef5aab857229d..44eddf01a982161bf5384a76f4b90a6cc73c1134 100644 (file)
@@ -59,6 +59,7 @@ void SkRefDict::set(const char name[], SkRefCnt* data) {
                 } else {
                     fImpl = rec->fNext;
                 }
+                delete rec;
             }
             return;
         }
index c4cffeafab3202cf8693f9749bb0b16f39a5759d..b25979ca8ddf09db9ae5521dbe7302e16f63a757 100644 (file)
@@ -539,9 +539,9 @@ GrEffectRef* GrMatrixConvolutionEffect::TestCreate(SkMWCRandom* random,
     int width = random->nextRangeU(1, MAX_KERNEL_SIZE);
     int height = random->nextRangeU(1, MAX_KERNEL_SIZE / width);
     SkISize kernelSize = SkISize::Make(width, height);
-    SkScalar* kernel = new SkScalar[width * height];
+    SkAutoTDeleteArray<SkScalar> kernel(new SkScalar[width * height]);
     for (int i = 0; i < width * height; i++) {
-        kernel[i] = random->nextSScalar1();
+        kernel.get()[i] = random->nextSScalar1();
     }
     SkScalar gain = random->nextSScalar1();
     SkScalar bias = random->nextSScalar1();
@@ -551,13 +551,12 @@ GrEffectRef* GrMatrixConvolutionEffect::TestCreate(SkMWCRandom* random,
     bool convolveAlpha = random->nextBool();
     return GrMatrixConvolutionEffect::Create(textures[texIdx],
                                              kernelSize,
-                                             kernel,
+                                             kernel.get(),
                                              gain,
                                              bias,
                                              target,
                                              tileMode,
                                              convolveAlpha);
-
 }
 
 bool SkMatrixConvolutionImageFilter::asNewEffect(GrEffectRef** effect,
index 269e359022877bc1cc60624b56b0daa70e79d61c..bdeafd4ff9f7ee8bb8ba4ee713cdc86237a3b451 100644 (file)
@@ -80,6 +80,8 @@ static bool bits_isonly(int value, int mask) {
 static void test_constructor(skiatest::Reporter* reporter) {
     // Allocate a matrix on the heap
     SkMatrix44* placeholderMatrix = new SkMatrix44();
+    SkAutoTDelete<SkMatrix44> deleteMe(placeholderMatrix);
+
     for (int row = 0; row < 4; ++row) {
         for (int col = 0; col < 4; ++col) {
             placeholderMatrix->setDouble(row, col, row * col);
index cc89d6b80646562624d16e3b34331ffc5085812f..7f6bc3485d6caa6b0b98e8e6aa88d6d93f5938b9 100644 (file)
@@ -225,7 +225,7 @@ static void TestSubstitute(skiatest::Reporter* reporter) {
 // and there is no assert on input data in Debug mode.
 static void test_issue1083() {
     SkISize pageSize = SkISize::Make(100, 100);
-    SkPDFDevice* dev = new SkPDFDevice(pageSize, pageSize, SkMatrix::I());
+    SkAutoTUnref<SkPDFDevice> dev(new SkPDFDevice(pageSize, pageSize, SkMatrix::I()));
 
     SkCanvas c(dev);
     SkPaint paint;