summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorglen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-04 05:00:20 +0000
committerglen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-04 05:00:20 +0000
commit9144b709860f43daa89385467131f3abd0a73df4 (patch)
treef6da7a5135b937017fec05a0cacec7d34f65d53b /base
parent9dedf70d00c9d4d5cbd908f219e81b331f0945bf (diff)
downloadchromium_src-9144b709860f43daa89385467131f3abd0a73df4.zip
chromium_src-9144b709860f43daa89385467131f3abd0a73df4.tar.gz
chromium_src-9144b709860f43daa89385467131f3abd0a73df4.tar.bz2
Fix leak in PNGEncoder.
R=willchan BUG=none TEST=none Review URL: http://codereview.chromium.org/119147 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17603 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/gfx/png_encoder.cc20
1 files changed, 10 insertions, 10 deletions
diff --git a/base/gfx/png_encoder.cc b/base/gfx/png_encoder.cc
index d9e22db..20aa042 100644
--- a/base/gfx/png_encoder.cc
+++ b/base/gfx/png_encoder.cc
@@ -204,8 +204,8 @@ bool PNGEncoder::EncodeBGRASkBitmap(const SkBitmap& input,
DCHECK(input.empty() || input.bytesPerPixel() == bbp);
// SkBitmaps are premultiplied, we need to unpremultiply them.
- scoped_ptr<unsigned char> divided;
- divided.reset(new unsigned char[input.width() * input.height() * bbp]);
+ scoped_array<unsigned char> divided(
+ new unsigned char[input.width() * input.height() * bbp]);
SkAutoLockPixels lock_input(input);
int i = 0;
@@ -214,15 +214,15 @@ bool PNGEncoder::EncodeBGRASkBitmap(const SkBitmap& input,
for (int x = 0; x < input.width(); x++) {
int alpha = SkColorGetA(src_row[x]);
if (alpha != 0 && alpha != 255) {
- divided.get()[i + 0] = (SkColorGetR(src_row[x]) << 8) / alpha;
- divided.get()[i + 1] = (SkColorGetG(src_row[x]) << 8) / alpha;
- divided.get()[i + 2] = (SkColorGetB(src_row[x]) << 8) / alpha;
- divided.get()[i + 3] = alpha;
+ divided[i + 0] = (SkColorGetR(src_row[x]) << 8) / alpha;
+ divided[i + 1] = (SkColorGetG(src_row[x]) << 8) / alpha;
+ divided[i + 2] = (SkColorGetB(src_row[x]) << 8) / alpha;
+ divided[i + 3] = alpha;
} else {
- divided.get()[i + 0] = SkColorGetR(src_row[x]);
- divided.get()[i + 1] = SkColorGetG(src_row[x]);
- divided.get()[i + 2] = SkColorGetB(src_row[x]);
- divided.get()[i + 3] = SkColorGetA(src_row[x]);
+ divided[i + 0] = SkColorGetR(src_row[x]);
+ divided[i + 1] = SkColorGetG(src_row[x]);
+ divided[i + 2] = SkColorGetB(src_row[x]);
+ divided[i + 3] = SkColorGetA(src_row[x]);
}
i += bbp;
}