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 "modules/skottie/include/Skottie.h" 11#include "src/core/SkFontMgrPriv.h" 12#include "tools/fonts/TestFontMgr.h" 13 14void FuzzSkottieJSON(sk_sp<SkData> bytes) { 15 SkMemoryStream stream(bytes); 16 auto animation = skottie::Animation::Make(&stream); 17 if (!animation) { 18 return; 19 } 20 animation->seek(0.1337f); // A "nothing up my sleeve" number 21} 22 23#if defined(SK_BUILD_FOR_LIBFUZZER) 24extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { 25 gSkFontMgr_DefaultFactory = &ToolUtils::MakePortableFontMgr; 26 auto bytes = SkData::MakeWithoutCopy(data, size); 27 FuzzSkottieJSON(bytes); 28 return 0; 29} 30#endif 31