fix auto-delete bug that crept in with new fast blur path; is causing
some of the valgrind errors.

BUG=skia:2111
R=bsalomon@google.com, robertphillips@google.com

Author: humper@google.com

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

git-svn-id: http://skia.googlecode.com/svn/trunk@13257 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/core/SkTemplates.h b/include/core/SkTemplates.h
index 76254e0..a3a8466 100644
--- a/include/core/SkTemplates.h
+++ b/include/core/SkTemplates.h
@@ -178,6 +178,13 @@
     void    free() { SkDELETE_ARRAY(fArray); fArray = NULL; }
     T*      detach() { T* array = fArray; fArray = NULL; return array; }
 
+    void reset(T array[]) {
+        if (fArray != array) {
+            SkDELETE_ARRAY(fArray);
+            fArray = array;
+        }
+    }
+
 private:
     T*  fArray;
 };
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index 2fffd05..03eedd2 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -646,13 +646,14 @@
     GrCacheID horizontalCacheID(gBlurProfileDomain, key);
     
     uint8_t *profile = NULL;
-    SkAutoTDeleteArray<uint8_t> ada(profile);
+    SkAutoTDeleteArray<uint8_t> ada(NULL);
     
     *horizontalScanline = context->findAndRefTexture(texDesc, horizontalCacheID, &params);
     
     if (NULL == *horizontalScanline) {
     
         SkBlurMask::ComputeBlurProfile(sigma, &profile);
+        ada.reset(profile);
         
         SkAutoTMalloc<uint8_t> horizontalPixels(width);
         SkBlurMask::ComputeBlurredScanline(horizontalPixels, profile, width, sigma);
@@ -675,6 +676,7 @@
     if (NULL == *verticalScanline) {
         if (NULL == profile) {
             SkBlurMask::ComputeBlurProfile(sigma, &profile);
+            ada.reset(profile);
         }
         
         SkAutoTMalloc<uint8_t> verticalPixels(height);