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