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: tests/IndexedPngOverflowTest.cpp

Issue 948163002: Indexed PNG decoding: Ensure color table is large enough that the bit depth of the image will not a… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 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
OLDNEW
(Empty)
1 /*
2 * Copyright 2011 Google Inc.
scroggo 2015/03/05 23:23:30 2015*
David Lattimore 2015/03/06 00:15:26 Done.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkBitmap.h"
9 #include "SkBitmapDevice.h"
10 #include "SkCanvas.h"
11 #include "SkDevice.h"
12 #include "SkForceLinking.h"
13 #include "SkImageDecoder.h"
14 #include "SkImageInfo.h"
15 #include "Test.h"
16
17 // A 20x1 image with 8 bits per pixel and a palette size of 0. Pixel values are 255, 254... Run
18 // this test with ASAN to make sure we don't try to access before/after any pale tte-sized buffers.
19 unsigned char a_png[] = {
scroggo 2015/03/05 23:23:30 gPng*
David Lattimore 2015/03/06 00:15:26 Done.
20 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
21 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01,
22 0x08, 0x03, 0x00, 0x00, 0x00, 0xe9, 0x4c, 0x7e, 0x17, 0x00, 0x00, 0x00,
23 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00,
24 0x1c, 0x00, 0x0f, 0x01, 0xb9, 0x8f, 0x00, 0x00, 0x00, 0x00, 0x50, 0x4c,
25 0x54, 0x45, 0x4b, 0xa8, 0x89, 0x55, 0x00, 0x00, 0x00, 0x20, 0x49, 0x44,
26 0x41, 0x54, 0x78, 0xda, 0xed, 0xfd, 0x07, 0x01, 0x00, 0x20, 0x08, 0x00,
27 0x41, 0xbc, 0x5b, 0xe8, 0xdf, 0x97, 0x99, 0xe3, 0x92, 0xa0, 0xf2, 0xdf,
28 0x3d, 0x7b, 0x0d, 0xda, 0x04, 0x1c, 0x03, 0xad, 0x00, 0x38, 0x5c, 0x2e,
29 0xad, 0x12, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42,
30 0x60, 0x82
31 };
32
33 DEF_TEST(IndexedPngOverflow, reporter) {
34 SkBitmap image;
35 SkForceLinking(false);
36 bool success = SkImageDecoder::DecodeMemory(
37 a_png, sizeof(a_png), &image, SkColorType::kUnknown_SkColorType,
38 SkImageDecoder::kDecodePixels_Mode);
39 REPORTER_ASSERT(reporter, success);
40
41 SkBitmap bitmap;
42 bitmap.setInfo(SkImageInfo::MakeN32Premul(20, 1)
43 .makeColorType(kBGRA_8888_SkColorType));
scroggo 2015/03/05 23:23:30 Is there a reason you want BGRA instead of N32 (wh
David Lattimore 2015/03/06 00:15:26 Nope. I just based this off some other code I had
44 bitmap.allocPixels();
45 SkBaseDevice* device = new SkBitmapDevice(bitmap);
46 SkCanvas* canvas = new SkCanvas(device);
scroggo 2015/03/05 23:23:30 This is the old way of creating an SkCanvas. Here'
David Lattimore 2015/03/06 00:15:26 Done.
47 SkRect destRect = SkRect::MakeXYWH(0, 0, 20, 1);
48 canvas->drawBitmapRect(image, destRect, nullptr);
scroggo 2015/03/05 23:23:30 nit: Most of our code uses NULL. (The only excepti
David Lattimore 2015/03/06 00:15:26 Done.
49 canvas->unref();
50 device->unref();
51 }
OLDNEW
« src/images/SkImageDecoder_libpng.cpp ('K') | « src/images/SkImageDecoder_libpng.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698