FuzzJSON.cpp 633 B

123456789101112131415161718192021222324
  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. #include "include/core/SkData.h"
  8. #include "include/core/SkStream.h"
  9. #include "src/utils/SkJSON.h"
  10. void FuzzJSON(sk_sp<SkData> bytes) {
  11. skjson::DOM dom(static_cast<const char*>(bytes->data()), bytes->size());
  12. SkDynamicMemoryWStream wstream;
  13. dom.write(&wstream);
  14. }
  15. #if defined(IS_FUZZING_WITH_LIBFUZZER)
  16. extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
  17. auto bytes = SkData::MakeWithoutCopy(data, size);
  18. FuzzJSON(bytes);
  19. return 0;
  20. }
  21. #endif