1 /* 2 * Copyright 2014 Google Inc. 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 "Resources.h" 9 #include "Test.h" 10 11 #include "SkBitmap.h" 12 #include "SkCodec.h" 13 #include "SkOSFile.h" 14 #include "SkOSPath.h" 15 #include "SkStream.h" 16 17 DEF_TEST(BadImage, reporter) { 18 const char* const badImages [] = { 19 "sigabort_favicon.ico", 20 "sigsegv_favicon.ico", 21 "sigsegv_favicon_2.ico", 22 "ico_leak01.ico", 23 "ico_fuzz0.ico", 24 "ico_fuzz1.ico", 25 "skbug3442.webp", 26 "skbug3429.webp", 27 "b38116746.ico", 28 }; 29 30 const char* badImagesFolder = "invalid_images"; 31 32 for (size_t i = 0; i < SK_ARRAY_COUNT(badImages); ++i) { 33 SkString resourcePath = SkOSPath::Join(badImagesFolder, badImages[i]); 34 std::unique_ptr<SkStream> stream(GetResourceAsStream(resourcePath.c_str())); 35 std::unique_ptr<SkCodec> codec(SkCodec::MakeFromStream(std::move(stream))); 36 37 // These images are corrupt. It's not important whether we succeed/fail in codec 38 // creation or decoding. We just want to make sure that we don't crash. 39 if (codec) { 40 SkBitmap bm; 41 bm.allocPixels(codec->getInfo()); 42 codec->getPixels(codec->getInfo(), bm.getPixels(), 43 bm.rowBytes()); 44 } 45 } 46 } 47