xref: /third_party/skia/fuzz/oss_fuzz/FuzzJSON.cpp
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/skia/fuzz/oss_fuzz/
1cb93a386Sopenharmony_ci/*
2cb93a386Sopenharmony_ci * Copyright 2018 Google, LLC
3cb93a386Sopenharmony_ci *
4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be
5cb93a386Sopenharmony_ci * found in the LICENSE file.
6cb93a386Sopenharmony_ci */
7cb93a386Sopenharmony_ci
8cb93a386Sopenharmony_ci#include "include/core/SkData.h"
9cb93a386Sopenharmony_ci#include "include/core/SkStream.h"
10cb93a386Sopenharmony_ci#include "src/utils/SkJSON.h"
11cb93a386Sopenharmony_ci
12cb93a386Sopenharmony_civoid FuzzJSON(sk_sp<SkData> bytes) {
13cb93a386Sopenharmony_ci    skjson::DOM dom(static_cast<const char*>(bytes->data()), bytes->size());
14cb93a386Sopenharmony_ci    SkDynamicMemoryWStream wstream;
15cb93a386Sopenharmony_ci    dom.write(&wstream);
16cb93a386Sopenharmony_ci}
17cb93a386Sopenharmony_ci
18cb93a386Sopenharmony_ci// TODO(kjlubick): remove IS_FUZZING... after https://crrev.com/c/2410304 lands
19cb93a386Sopenharmony_ci#if defined(SK_BUILD_FOR_LIBFUZZER) || defined(IS_FUZZING_WITH_LIBFUZZER)
20cb93a386Sopenharmony_ciextern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
21cb93a386Sopenharmony_ci    auto bytes = SkData::MakeWithoutCopy(data, size);
22cb93a386Sopenharmony_ci    FuzzJSON(bytes);
23cb93a386Sopenharmony_ci    return 0;
24cb93a386Sopenharmony_ci}
25cb93a386Sopenharmony_ci#endif
26

Indexes created Thu Nov 07 10:32:03 CST 2024