2014-11-10 21:12:25 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2014 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Resources.h"
|
|
|
|
#include "Test.h"
|
2016-11-07 23:05:29 +00:00
|
|
|
|
2014-11-10 21:12:25 +00:00
|
|
|
#include "SkBitmap.h"
|
2016-03-01 20:12:27 +00:00
|
|
|
#include "SkCodec.h"
|
2014-11-10 21:12:25 +00:00
|
|
|
#include "SkOSFile.h"
|
2016-11-07 23:05:29 +00:00
|
|
|
#include "SkOSPath.h"
|
|
|
|
#include "SkStream.h"
|
2014-11-10 21:12:25 +00:00
|
|
|
|
2015-07-10 16:32:09 +00:00
|
|
|
DEF_TEST(BadImage, reporter) {
|
|
|
|
const char* const badImages [] = {
|
2014-11-10 21:12:25 +00:00
|
|
|
"sigabort_favicon.ico",
|
|
|
|
"sigsegv_favicon.ico",
|
|
|
|
"sigsegv_favicon_2.ico",
|
2015-03-13 15:07:01 +00:00
|
|
|
"ico_leak01.ico",
|
|
|
|
"ico_fuzz0.ico",
|
2015-07-10 16:32:09 +00:00
|
|
|
"ico_fuzz1.ico",
|
|
|
|
"skbug3442.webp",
|
|
|
|
"skbug3429.webp",
|
2014-11-10 21:12:25 +00:00
|
|
|
};
|
|
|
|
|
2015-07-10 16:32:09 +00:00
|
|
|
const char* badImagesFolder = "invalid_images";
|
2014-11-10 21:12:25 +00:00
|
|
|
|
2015-07-10 16:32:09 +00:00
|
|
|
for (size_t i = 0; i < SK_ARRAY_COUNT(badImages); ++i) {
|
2016-09-16 13:24:20 +00:00
|
|
|
SkString resourcePath = SkOSPath::Join(badImagesFolder, badImages[i]);
|
2016-11-03 18:40:50 +00:00
|
|
|
std::unique_ptr<SkStream> stream(GetResourceAsStream(resourcePath.c_str()));
|
|
|
|
std::unique_ptr<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
|
2016-03-01 20:12:27 +00:00
|
|
|
|
|
|
|
// These images are corrupt. It's not important whether we succeed/fail in codec
|
|
|
|
// creation or decoding. We just want to make sure that we don't crash.
|
|
|
|
if (codec) {
|
|
|
|
SkBitmap bm;
|
|
|
|
bm.allocPixels(codec->getInfo());
|
|
|
|
codec->getPixels(codec->getInfo(), bm.getPixels(),
|
|
|
|
bm.rowBytes());
|
|
|
|
}
|
2014-11-10 21:12:25 +00:00
|
|
|
}
|
|
|
|
}
|