blob: 252fd8de6867fa5dc0c89dba582db0274dc9f203 [file] [log] [blame]
Kevin Lubick9eeede22018-05-03 16:26:10 -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
8#include "SkData.h"
Kevin Lubickec1c6202018-12-14 11:42:53 -05009#include "SkFontMgrPriv.h"
Kevin Lubick9eeede22018-05-03 16:26:10 -040010#include "SkStream.h"
Kevin Lubickec1c6202018-12-14 11:42:53 -050011#include "SkTestFontMgr.h"
12#include "Skottie.h"
Kevin Lubick9eeede22018-05-03 16:26:10 -040013
14void FuzzSkottieJSON(sk_sp<SkData> bytes) {
Kevin Lubick9eeede22018-05-03 16:26:10 -040015 SkMemoryStream stream(bytes);
Florin Malitac83a0de2018-05-31 12:17:55 -040016 auto animation = skottie::Animation::Make(&stream);
Kevin Lubick9eeede22018-05-03 16:26:10 -040017 if (!animation) {
18 return;
19 }
Florin Malitaa33447d2018-05-29 13:46:54 -040020 animation->seek(0.1337f); // A "nothing up my sleeve" number
Kevin Lubick9eeede22018-05-03 16:26:10 -040021}
22
23#if defined(IS_FUZZING_WITH_LIBFUZZER)
24extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
Kevin Lubickec1c6202018-12-14 11:42:53 -050025 gSkFontMgr_DefaultFactory = &sk_tool_utils::MakePortableFontMgr;
Kevin Lubick9eeede22018-05-03 16:26:10 -040026 auto bytes = SkData::MakeWithoutCopy(data, size);
27 FuzzSkottieJSON(bytes);
28 return 0;
29}
30#endif