blob: d94676bcb11f329640c05cb8a51d85008d29d507 [file] [log] [blame]
Florin Malita7796f002018-06-08 12:25:38 -04001/*
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 Kleinc0bd9f92019-04-23 12:05:21 -05008#include "include/core/SkData.h"
9#include "include/core/SkStream.h"
10#include "src/utils/SkJSON.h"
Florin Malita7796f002018-06-08 12:25:38 -040011
Florin Malita80452be2018-06-19 11:27:20 -040012void FuzzJSON(sk_sp<SkData> bytes) {
Florin Malitafedfd542018-06-14 15:03:21 -040013 skjson::DOM dom(static_cast<const char*>(bytes->data()), bytes->size());
Florin Malita7796f002018-06-08 12:25:38 -040014 SkDynamicMemoryWStream wstream;
15 dom.write(&wstream);
16}
17
Kevin Lubickb45d0ca2020-09-14 13:31:25 -040018// 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 Malita7796f002018-06-08 12:25:38 -040020extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
21 auto bytes = SkData::MakeWithoutCopy(data, size);
Florin Malita80452be2018-06-19 11:27:20 -040022 FuzzJSON(bytes);
Florin Malita7796f002018-06-08 12:25:38 -040023 return 0;
24}
25#endif