Debian Codegraph @

fuzz/oss_fuzz/FuzzRegionSetPath.cpp

raw
1 /*
2 * Copyright 2018 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
8 #include "fuzz/Fuzz.h"
9 #include "fuzz/FuzzCommon.h"
10 #include "include/core/SkPath.h"
11 #include "include/core/SkRegion.h"
12
13
14 void FuzzRegionSetPath(Fuzz* fuzz) {
15 SkPath p = FuzzNicePath(fuzz, 1000);
16 SkRegion r1;
17 bool initR1;
18 fuzz->next(&initR1);
19 if (initR1) {
20 fuzz->next(&r1);
21 }
22 SkRegion r2;
23 fuzz->next(&r2);
24
25 r1.setPath(p, r2);
26
27 // Do some follow on computations to make sure region is well-formed.
28 r1.computeRegionComplexity();
29 r1.isComplex();
30 if (r1 == r2) {
31 r1.contains(0,0);
32 } else {
33 r1.contains(1,1);
34 }
35 }
36
37 #if defined(SK_BUILD_FOR_LIBFUZZER)
38 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
39 if (size > 512) {
40 return 0;
41 }
42 Fuzz fuzz(data, size);
43 FuzzRegionSetPath(&fuzz);
44 return 0;
45 }
46 #endif