[go: nahoru, domu]

When cloning into an SkPicture, clear its data.

Prevents a memory leak if the caller clones into an SkPicture
that already has a playback or record.

Review URL: https://codereview.appspot.com/6813081

git-svn-id: http://skia.googlecode.com/svn/trunk/src@6282 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/core/SkPicture.cpp b/core/SkPicture.cpp
index 4109524..564a829 100644
--- a/core/SkPicture.cpp
+++ b/core/SkPicture.cpp
@@ -157,6 +157,12 @@
         clone->fHeight = fHeight;
         clone->fRecord = NULL;
 
+        if (NULL != clone->fRecord) {
+            clone->fRecord->unref();
+            clone->fRecord = NULL;
+        }
+        SkDELETE(clone->fPlayback);
+
         /*  We want to copy the src's playback. However, if that hasn't been built
             yet, we need to fake a call to endRecording() without actually calling
             it (since it is destructive, and we don't want to change src).