Florin Malita | 7796f00 | 2018-06-08 12:25:38 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 Google, LLC |
| 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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "include/core/SkData.h" |
| 9 | #include "include/core/SkStream.h" |
| 10 | #include "src/utils/SkJSON.h" |
Florin Malita | 7796f00 | 2018-06-08 12:25:38 -0400 | [diff] [blame] | 11 | |
Florin Malita | 80452be | 2018-06-19 11:27:20 -0400 | [diff] [blame] | 12 | void FuzzJSON(sk_sp<SkData> bytes) { |
Florin Malita | fedfd54 | 2018-06-14 15:03:21 -0400 | [diff] [blame] | 13 | skjson::DOM dom(static_cast<const char*>(bytes->data()), bytes->size()); |
Florin Malita | 7796f00 | 2018-06-08 12:25:38 -0400 | [diff] [blame] | 14 | SkDynamicMemoryWStream wstream; |
| 15 | dom.write(&wstream); |
| 16 | } |
| 17 | |
Kevin Lubick | b45d0ca | 2020-09-14 13:31:25 -0400 | [diff] [blame] | 18 | // TODO(kjlubick): remove IS_FUZZING... after https://crrev.com/c/2410304 lands |
| 19 | #if defined(SK_BUILD_FOR_LIBFUZZER) || defined(IS_FUZZING_WITH_LIBFUZZER) |
Florin Malita | 7796f00 | 2018-06-08 12:25:38 -0400 | [diff] [blame] | 20 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { |
| 21 | auto bytes = SkData::MakeWithoutCopy(data, size); |
Florin Malita | 80452be | 2018-06-19 11:27:20 -0400 | [diff] [blame] | 22 | FuzzJSON(bytes); |
Florin Malita | 7796f00 | 2018-06-08 12:25:38 -0400 | [diff] [blame] | 23 | return 0; |
| 24 | } |
| 25 | #endif |