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