Flutter Engine
The Flutter Engine
BadIcoTest.cpp
Go to the documentation of this file.
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
13#include "src/utils/SkOSPath.h"
14#include "tests/Test.h"
15#include "tools/Resources.h"
16
17#include <array>
18#include <cstddef>
19#include <memory>
20#include <utility>
21
22DEF_TEST(BadImage, reporter) {
23 const char* const badImages [] = {
24 "sigabort_favicon.ico",
25 "sigsegv_favicon.ico",
26 "sigsegv_favicon_2.ico",
27 "ico_leak01.ico",
28 "ico_fuzz0.ico",
29 "ico_fuzz1.ico",
30 "skbug3442.webp",
31 "skbug3429.webp",
32 "b38116746.ico",
33 "skbug5883.gif",
34 };
35
36 const char* badImagesFolder = "invalid_images";
37
38 for (size_t i = 0; i < std::size(badImages); ++i) {
39 SkString resourcePath = SkOSPath::Join(badImagesFolder, badImages[i]);
40 std::unique_ptr<SkStream> stream(GetResourceAsStream(resourcePath.c_str()));
41 std::unique_ptr<SkCodec> codec(SkCodec::MakeFromStream(std::move(stream)));
42
43 // These images are corrupt. It's not important whether we succeed/fail in codec
44 // creation or decoding. We just want to make sure that we don't crash.
45 if (codec) {
46 SkBitmap bm;
47 bm.allocPixels(codec->getInfo());
48 codec->getPixels(codec->getInfo(), bm.getPixels(),
49 bm.rowBytes());
50 }
51 }
52}
DEF_TEST(BadImage, reporter)
Definition: BadIcoTest.cpp:22
reporter
Definition: FontMgrTest.cpp:39
std::unique_ptr< SkStreamAsset > GetResourceAsStream(const char *resource, bool useFileStream)
Definition: Resources.cpp:31
void allocPixels(const SkImageInfo &info, size_t rowBytes)
Definition: SkBitmap.cpp:258
size_t rowBytes() const
Definition: SkBitmap.h:238
void * getPixels() const
Definition: SkBitmap.h:283
static std::unique_ptr< SkCodec > MakeFromStream(std::unique_ptr< SkStream >, SkSpan< const SkCodecs::Decoder > decoders, Result *=nullptr, SkPngChunkReader *=nullptr, SelectionPolicy selectionPolicy=SelectionPolicy::kPreferStillImage)
Definition: SkCodec.cpp:163
static SkString Join(const char *rootPath, const char *relativePath)
Definition: SkOSPath.cpp:14
const char * c_str() const
Definition: SkString.h:133
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259