|  | // Copyright 2016 The Chromium Authors. All rights reserved. | 
|  | // Use of this source code is governed by a BSD-style license that can be | 
|  | // found in the LICENSE file. | 
|  |  | 
|  | #include <stddef.h> | 
|  | #include <stdint.h> | 
|  |  | 
|  | #include "testing/libfuzzer/fuzzers/skia_path_common.h" | 
|  | #include "third_party/skia/include/core/SkPath.h" | 
|  | #include "third_party/skia/include/pathops/SkPathOps.h" | 
|  |  | 
|  | const int kLastOp = SkPathOp::kReverseDifference_SkPathOp; | 
|  |  | 
|  | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { | 
|  | SkOpBuilder builder; | 
|  | while (size > 0) { | 
|  | SkPath path; | 
|  | uint8_t op; | 
|  | if (!read<uint8_t>(&data, &size, &op)) | 
|  | break; | 
|  |  | 
|  | BuildPath(&data, &size, &path, SkPath::Verb::kDone_Verb); | 
|  | builder.add(path, static_cast<SkPathOp>(op % (kLastOp + 1))); | 
|  | } | 
|  |  | 
|  | SkPath result; | 
|  | builder.resolve(&result); | 
|  | return 0; | 
|  | } |