Flutter Engine
The Flutter Engine
Functions
BadIcoTest.cpp File Reference
#include "include/codec/SkCodec.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkStream.h"
#include "include/core/SkString.h"
#include "include/core/SkTypes.h"
#include "src/utils/SkOSPath.h"
#include "tests/Test.h"
#include "tools/Resources.h"
#include <array>
#include <cstddef>
#include <memory>
#include <utility>

Go to the source code of this file.

Functions

 DEF_TEST (BadImage, reporter)
 

Function Documentation

◆ DEF_TEST()

DEF_TEST ( BadImage  ,
reporter   
)

Definition at line 22 of file BadIcoTest.cpp.

22 {
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}
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