diff options
author | 2012-11-02 20:51:19 +0000 | |
---|---|---|
committer | 2012-11-02 20:51:19 +0000 | |
commit | de1390db929c770405b6bb98b983d4e81fb74882 (patch) | |
tree | 8a6d0eedd29f75b879c5d244b6208cd7675b78cc /src/core | |
parent | b4a55b7b68bf6b8ba8cb12927e5a627fab95ea5c (diff) |
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@6282 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkPicture.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp index 410952479b..564a829d33 100644 --- a/src/core/SkPicture.cpp +++ b/src/core/SkPicture.cpp @@ -157,6 +157,12 @@ void SkPicture::clone(SkPicture* pictures, int count) const { 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). |