Coverage Report

Created: 2024-05-20 07:14

/src/skia/fuzz/oss_fuzz/FuzzRegionSetPath.cpp
Line
Count
Source
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
6.70k
void FuzzRegionSetPath(Fuzz* fuzz) {
15
6.70k
    SkPath p;
16
6.70k
    FuzzNicePath(fuzz, &p, 1000);
17
6.70k
    SkRegion r1;
18
6.70k
    bool initR1;
19
6.70k
    fuzz->next(&initR1);
20
6.70k
    if (initR1) {
21
498
        fuzz->next(&r1);
22
498
    }
23
6.70k
    SkRegion r2;
24
6.70k
    fuzz->next(&r2);
25
26
6.70k
    r1.setPath(p, r2);
27
28
    // Do some follow on computations to make sure region is well-formed.
29
6.70k
    r1.computeRegionComplexity();
30
6.70k
    r1.isComplex();
31
6.70k
    if (r1 == r2) {
32
5.15k
        r1.contains(0,0);
33
5.15k
    } else {
34
1.55k
        r1.contains(1,1);
35
1.55k
    }
36
6.70k
}
37
38
#if defined(SK_BUILD_FOR_LIBFUZZER)
39
190k
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
40
190k
    if (size > 512) {
41
220
        return 0;
42
220
    }
43
190k
    Fuzz fuzz(data, size);
44
190k
    FuzzRegionSetPath(&fuzz);
45
190k
    return 0;
46
190k
}
47
#endif