| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "Resources.h" | 8 #include "Resources.h" |
| 9 #include "Test.h" | 9 #include "Test.h" |
| 10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
| 11 #include "SkImageDecoder.h" | 11 #include "SkImageDecoder.h" |
| 12 #include "SkOSFile.h" | 12 #include "SkOSFile.h" |
| 13 | 13 |
| 14 DEF_TEST(BadImage, reporter) { | 14 DEF_TEST(BadIco, reporter) { |
| 15 const char* const badImages [] = { | 15 const char* const badIcos [] = { |
| 16 "sigabort_favicon.ico", | 16 "sigabort_favicon.ico", |
| 17 "sigsegv_favicon.ico", | 17 "sigsegv_favicon.ico", |
| 18 "sigsegv_favicon_2.ico", | 18 "sigsegv_favicon_2.ico", |
| 19 "ico_leak01.ico", | 19 "ico_leak01.ico", |
| 20 "ico_fuzz0.ico", | 20 "ico_fuzz0.ico", |
| 21 "ico_fuzz1.ico", | 21 "ico_fuzz1.ico" |
| 22 "skbug3442.webp", | |
| 23 "skbug3429.webp", | |
| 24 }; | 22 }; |
| 25 | 23 |
| 26 const char* badImagesFolder = "invalid_images"; | 24 const char* badIcoFolder = "invalid_images"; |
| 27 | 25 |
| 28 SkString resourcePath = GetResourcePath(badImagesFolder); | 26 SkString resourcePath = GetResourcePath(badIcoFolder); |
| 29 | 27 |
| 30 SkBitmap bm; | 28 SkBitmap bm; |
| 31 for (size_t i = 0; i < SK_ARRAY_COUNT(badImages); ++i) { | 29 for (size_t i = 0; i < SK_ARRAY_COUNT(badIcos); ++i) { |
| 32 SkString fullPath = SkOSPath::Join(resourcePath.c_str(), badImages[i]); | 30 SkString fullPath = SkOSPath::Join(resourcePath.c_str(), badIcos[i]); |
| 33 bool success = SkImageDecoder::DecodeFile(fullPath.c_str(), &bm); | 31 bool success = SkImageDecoder::DecodeFile(fullPath.c_str(), &bm); |
| 34 // These files are invalid, and should not decode. More importantly, | 32 // These files are invalid, and should not decode. More importantly, |
| 35 // though, we reached here without crashing. | 33 // though, we reached here without crashing. |
| 36 REPORTER_ASSERT(reporter, !success); | 34 REPORTER_ASSERT(reporter, !success); |
| 37 } | 35 } |
| 38 } | 36 } |
| OLD | NEW |