diff options
Diffstat (limited to 'fuzz/oss_fuzz/FuzzRegionSetPath.cpp')
-rw-r--r-- | fuzz/oss_fuzz/FuzzRegionSetPath.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/fuzz/oss_fuzz/FuzzRegionSetPath.cpp b/fuzz/oss_fuzz/FuzzRegionSetPath.cpp new file mode 100644 index 0000000000..e51a4c03f0 --- /dev/null +++ b/fuzz/oss_fuzz/FuzzRegionSetPath.cpp @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "../Fuzz.h" +#include "../FuzzCommon.h" +#include "SkData.h" +#include "SkPath.h" +#include "SkRegion.h" + + +void FuzzRegionSetPath(Fuzz* fuzz) { + SkPath p; + fuzz_path(fuzz, &p, 1000); + SkRegion r1; + bool initR1; + fuzz->next(&initR1); + if (initR1) { + fuzz->next(&r1); + } + SkRegion r2; + fuzz->next(&r2); + + r1.setPath(p, r2); + + // Do some follow on computations to make sure region is well-formed. + r1.computeRegionComplexity(); + r1.isComplex(); + if (r1 == r2) { + r1.contains(0,0); + } else { + r1.contains(1,1); + } +} + +#if defined(IS_FUZZING_WITH_LIBFUZZER) +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + sk_sp<SkData> bytes(SkData::MakeWithoutCopy(data, size)); + Fuzz fuzz(bytes); + FuzzRegionSetPath(&fuzz); + return 0; +} +#endif |