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

Side by Side Diff: src/codec/SkCodec_libpng.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, 8 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 unified diff | Download patch
« no previous file with comments | « src/codec/SkCodec_libgif.cpp ('k') | src/codec/SkCodec_wbmp.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkCodec_libpng.h" 8 #include "SkCodec_libpng.h"
9 #include "SkCodecPriv.h" 9 #include "SkCodecPriv.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 if (png_ptrp) { 339 if (png_ptrp) {
340 *png_ptrp = png_ptr; 340 *png_ptrp = png_ptr;
341 } 341 }
342 if (info_ptrp) { 342 if (info_ptrp) {
343 *info_ptrp = info_ptr; 343 *info_ptrp = info_ptr;
344 } 344 }
345 return true; 345 return true;
346 } 346 }
347 347
348 SkCodec* SkPngCodec::NewFromStream(SkStream* stream) { 348 SkCodec* SkPngCodec::NewFromStream(SkStream* stream) {
349 SkAutoTDelete<SkStream> streamDeleter(stream);
349 png_structp png_ptr; 350 png_structp png_ptr;
350 png_infop info_ptr; 351 png_infop info_ptr;
351 SkImageInfo imageInfo; 352 SkImageInfo imageInfo;
352 if (read_header(stream, &png_ptr, &info_ptr, &imageInfo)) { 353 if (read_header(stream, &png_ptr, &info_ptr, &imageInfo)) {
353 return SkNEW_ARGS(SkPngCodec, (imageInfo, stream, png_ptr, info_ptr)); 354 return SkNEW_ARGS(SkPngCodec, (imageInfo, streamDeleter.detach(), png_pt r, info_ptr));
354 } 355 }
355 return NULL; 356 return NULL;
356 } 357 }
357 358
358 #define INVALID_NUMBER_PASSES -1 359 #define INVALID_NUMBER_PASSES -1
359 SkPngCodec::SkPngCodec(const SkImageInfo& info, SkStream* stream, 360 SkPngCodec::SkPngCodec(const SkImageInfo& info, SkStream* stream,
360 png_structp png_ptr, png_infop info_ptr) 361 png_structp png_ptr, png_infop info_ptr)
361 : INHERITED(info, stream) 362 : INHERITED(info, stream)
362 , fPng_ptr(png_ptr) 363 , fPng_ptr(png_ptr)
363 , fInfo_ptr(info_ptr) 364 , fInfo_ptr(info_ptr)
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 638
638 SkASSERT(fNumberPasses != INVALID_NUMBER_PASSES); 639 SkASSERT(fNumberPasses != INVALID_NUMBER_PASSES);
639 if (fNumberPasses > 1) { 640 if (fNumberPasses > 1) {
640 // We cannot efficiently do scanline decoding. 641 // We cannot efficiently do scanline decoding.
641 return NULL; 642 return NULL;
642 } 643 }
643 644
644 return SkNEW_ARGS(SkPngScanlineDecoder, (dstInfo, this)); 645 return SkNEW_ARGS(SkPngScanlineDecoder, (dstInfo, this));
645 } 646 }
646 647
OLDNEW
« no previous file with comments | « src/codec/SkCodec_libgif.cpp ('k') | src/codec/SkCodec_wbmp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698