Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Functions | Variables
FuzzParsePath.cpp File Reference
#include "fuzz/Fuzz.h"
#include "include/core/SkString.h"
#include "include/utils/SkParsePath.h"
#include <stdlib.h>

Go to the source code of this file.

Classes

struct  Legal
 

Functions

static void add_white (Fuzz *fuzz, SkString *atom)
 
static void add_some_white (Fuzz *fuzz, SkString *atom)
 
static void add_comma (Fuzz *fuzz, SkString *atom)
 
SkString MakeRandomParsePathPiece (Fuzz *fuzz)
 
 DEF_FUZZ (ParsePath, fuzz)
 

Variables

static const struct Legal gLegal []
 
static bool gEasy = false
 
static const char gWhiteSpace [] = { 0, 0, 0, 0, 0, 0, 0, 0, ' ', ' ', ' ', ' ', 0x09, 0x0D, 0x0A }
 

Function Documentation

◆ add_comma()

static void add_comma ( Fuzz fuzz,
SkString atom 
)
static

Definition at line 62 of file FuzzParsePath.cpp.

62 {
63 if (gEasy) {
64 atom->append(",");
65 return;
66 }
67 add_white(fuzz, atom);
68 bool b;
69 fuzz->next(&b);
70 if (b) {
71 atom->append(",");
72 }
73 add_some_white(fuzz, atom);
74}
static void add_some_white(Fuzz *fuzz, SkString *atom)
static void add_white(Fuzz *fuzz, SkString *atom)
static bool gEasy
void next(T *t)
Definition Fuzz.h:64
void append(const char text[])
Definition SkString.h:203
static bool b

◆ add_some_white()

static void add_some_white ( Fuzz fuzz,
SkString atom 
)
static

Definition at line 56 of file FuzzParsePath.cpp.

56 {
57 for(int i = 0; i < 10; i++) {
58 add_white(fuzz, atom);
59 }
60}

◆ add_white()

static void add_white ( Fuzz fuzz,
SkString atom 
)
static

Definition at line 38 of file FuzzParsePath.cpp.

38 {
39 if (gEasy) {
40 atom->append(" ");
41 return;
42 }
43 // Use a uint8_t to conserve bytes. This makes our "fuzzed bytes footprint"
44 // smaller, which leads to more efficient fuzzing.
45 uint8_t reps;
46 fuzz->nextRange(&reps, 0, 2);
47 for (uint8_t rep = 0; rep < reps; ++rep) {
48 uint8_t index;
49 fuzz->nextRange(&index, 0, (int) std::size(gWhiteSpace) - 1);
50 if (gWhiteSpace[index]) {
51 atom->append(&gWhiteSpace[index], 1);
52 }
53 }
54}
static const char gWhiteSpace[]
void nextRange(T *, Min, Max)
Definition Fuzz.h:119

◆ DEF_FUZZ()

DEF_FUZZ ( ParsePath  ,
fuzz   
)

Definition at line 116 of file FuzzParsePath.cpp.

116 {
117 SkPath path;
118 SkString spec;
119 uint8_t count;
120 fuzz->nextRange(&count, 0, 40);
121 for (uint8_t i = 0; i < count; ++i) {
123 }
124 SkDebugf("SkParsePath::FromSVGString(%s, &path);\n",spec.c_str());
125 if (!SkParsePath::FromSVGString(spec.c_str(), &path)){
126 SkDebugf("Could not decode path\n");
127 }
128}
int count
SkString MakeRandomParsePathPiece(Fuzz *fuzz)
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static bool FromSVGString(const char str[], SkPath *)
const char * c_str() const
Definition SkString.h:133
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition switches.h:57

◆ MakeRandomParsePathPiece()

SkString MakeRandomParsePathPiece ( Fuzz fuzz)

Definition at line 76 of file FuzzParsePath.cpp.

76 {
77 SkString atom;
78 uint8_t legalIndex;
79 fuzz->nextRange(&legalIndex, 0, (int) std::size(gLegal) - 1);
80 const Legal& legal = gLegal[legalIndex];
81 gEasy ? atom.append("\n") : add_white(fuzz, &atom);
82 bool b;
83 fuzz->next(&b);
84 char symbol = legal.fSymbol | (b ? 0x20 : 0);
85 atom.append(&symbol, 1);
86 uint8_t reps;
87 fuzz->nextRange(&reps, 1, 3);
88 for (int rep = 0; rep < reps; ++rep) {
89 for (int index = 0; index < legal.fScalars; ++index) {
90 SkScalar coord;
91 fuzz->nextRange(&coord, 0.0f, 100.0f);
92 add_white(fuzz, &atom);
93 atom.appendScalar(coord);
94 if (rep < reps - 1 && index < legal.fScalars - 1) {
95 add_comma(fuzz, &atom);
96 } else {
97 add_some_white(fuzz, &atom);
98 }
99 if ('A' == legal.fSymbol && 1 == index) {
100 SkScalar s;
101 fuzz->nextRange(&s, -720.0f, 720.0f);
102 atom.appendScalar(s);
103 add_comma(fuzz, &atom);
104 fuzz->next(&b);
105 atom.appendU32(b);
106 add_comma(fuzz, &atom);
107 fuzz->next(&b);
108 atom.appendU32(b);
109 add_comma(fuzz, &atom);
110 }
111 }
112 }
113 return atom;
114}
static void add_comma(Fuzz *fuzz, SkString *atom)
static const struct Legal gLegal[]
void appendScalar(SkScalar value)
Definition SkString.h:213
void appendU32(uint32_t value)
Definition SkString.h:210
float SkScalar
Definition extension.cpp:12
struct MyStruct s
char fSymbol

Variable Documentation

◆ gEasy

bool gEasy = false
static

Definition at line 33 of file FuzzParsePath.cpp.

◆ gLegal

const struct Legal gLegal[]
static
Initial value:
= {
{ 'M', 2 },
{ 'H', 1 },
{ 'V', 1 },
{ 'L', 2 },
{ 'Q', 4 },
{ 'T', 2 },
{ 'C', 6 },
{ 'S', 4 },
{ 'A', 4 },
{ 'Z', 0 },
}

◆ gWhiteSpace

const char gWhiteSpace[] = { 0, 0, 0, 0, 0, 0, 0, 0, ' ', ' ', ' ', ' ', 0x09, 0x0D, 0x0A }
static

Definition at line 36 of file FuzzParsePath.cpp.

36{ 0, 0, 0, 0, 0, 0, 0, 0, ' ', ' ', ' ', ' ', 0x09, 0x0D, 0x0A };