skia2/fuzz/oss_fuzz/FuzzRegionSetPath.cpp
Kevin Lubick 2541edf0c6 Add in Region SetPath Fuzzer
Also refactor a few things to make it easier to use oss-fuzz.

Bug: skia:
Change-Id: Ie518a6cfc7d57a347b5d09089379f986d33f8b7f
Reviewed-on: https://skia-review.googlesource.com/41740
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2018-01-11 19:42:53 +00:00

47 lines
982 B
C++

/*
* 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