Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Unified Diff: src/codec/SkCodec_libgif.cpp

Issue 1058873006: Get rid of leaks in SkCodec::NewFromStream. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add comment that ReadHeader does not own SkStream. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/codec/SkCodec_libbmp.cpp ('k') | src/codec/SkCodec_libpng.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkCodec_libgif.cpp
diff --git a/src/codec/SkCodec_libgif.cpp b/src/codec/SkCodec_libgif.cpp
index 2a1d81fc00f99a71f3453579ee1ba49ad764442b..9356a6973bcba5995b1e3b330c4f6c981bd87f3e 100644
--- a/src/codec/SkCodec_libgif.cpp
+++ b/src/codec/SkCodec_libgif.cpp
@@ -136,6 +136,7 @@ static uint32_t find_trans_index(const SavedImage& image) {
* Reads enough of the stream to determine the image format
*/
SkCodec* SkGifCodec::NewFromStream(SkStream* stream) {
+ SkAutoTDelete<SkStream> streamDeleter(stream);
// Read gif header, logical screen descriptor, and global color table
SkAutoTCallIProc<GifFileType, CloseGif> gif(open_gif(stream));
@@ -165,7 +166,7 @@ SkCodec* SkGifCodec::NewFromStream(SkStream* stream) {
// use kPremul directly even when kUnpremul is supported.
const SkImageInfo& imageInfo = SkImageInfo::Make(width, height,
kIndex_8_SkColorType, kPremul_SkAlphaType);
- return SkNEW_ARGS(SkGifCodec, (imageInfo, stream, gif.detach()));
+ return SkNEW_ARGS(SkGifCodec, (imageInfo, streamDeleter.detach(), gif.detach()));
}
SkGifCodec::SkGifCodec(const SkImageInfo& srcInfo, SkStream* stream,
« no previous file with comments | « src/codec/SkCodec_libbmp.cpp ('k') | src/codec/SkCodec_libpng.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698