Fix codec memory leaks in nanobench
SubsetTranslateBench.cpp: Unref the color table, so it gets deleted. SkBitmapRegionDecoderInterface.cpp: Delete the stream if it is not used. BUG=skia:3418 Review URL: https://codereview.chromium.org/1396113003
This commit is contained in:
parent
e6dd004c1b
commit
e361781bf7
@ -140,7 +140,7 @@ void SubsetTranslateBench::onDraw(int n, SkCanvas* canvas) {
|
||||
// We create a color table here to satisfy allocPixels() when the output
|
||||
// type is kIndex8. It's okay that this is uninitialized since we never
|
||||
// use it.
|
||||
SkColorTable* colorTable = new SkColorTable(colors, 0);
|
||||
SkAutoTUnref<SkColorTable> colorTable(new SkColorTable(colors, 0));
|
||||
for (int count = 0; count < n; count++) {
|
||||
int width, height;
|
||||
SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStream));
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
SkBitmapRegionDecoderInterface* SkBitmapRegionDecoderInterface::CreateBitmapRegionDecoder(
|
||||
SkStreamRewindable* stream, Strategy strategy) {
|
||||
SkAutoTDelete<SkStreamRewindable> streamDeleter(stream);
|
||||
switch (strategy) {
|
||||
case kOriginal_Strategy: {
|
||||
SkImageDecoder* decoder = SkImageDecoder::Factory(stream);
|
||||
@ -21,7 +22,7 @@ SkBitmapRegionDecoderInterface* SkBitmapRegionDecoderInterface::CreateBitmapRegi
|
||||
SkDebugf("Error: Could not create image decoder.\n");
|
||||
return nullptr;
|
||||
}
|
||||
if (!decoder->buildTileIndex(stream, &width, &height)) {
|
||||
if (!decoder->buildTileIndex(streamDeleter.detach(), &width, &height)) {
|
||||
SkDebugf("Error: Could not build tile index.\n");
|
||||
delete decoder;
|
||||
return nullptr;
|
||||
@ -29,7 +30,7 @@ SkBitmapRegionDecoderInterface* SkBitmapRegionDecoderInterface::CreateBitmapRegi
|
||||
return new SkBitmapRegionSampler(decoder, width, height);
|
||||
}
|
||||
case kCanvas_Strategy: {
|
||||
SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream));
|
||||
SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(streamDeleter.detach()));
|
||||
if (nullptr == codec) {
|
||||
SkDebugf("Error: Failed to create decoder.\n");
|
||||
return nullptr;
|
||||
|
Loading…
Reference in New Issue
Block a user