blob: 88c5382f4ab6d3b9f4b08a837c64a17d8b3477be [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
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#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"
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
Kevin Lubick493f89e2020-09-14 08:37:35 -040023#if defined(SK_BUILD_FOR_LIBFUZZER)
Kevin Lubick9eeede22018-05-03 16:26:10 -040024extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
Mike Kleinea3f0142019-03-20 11:12:10 -050025 gSkFontMgr_DefaultFactory = &ToolUtils::MakePortableFontMgr;
Kevin Lubick9eeede22018-05-03 16:26:10 -040026 auto bytes = SkData::MakeWithoutCopy(data, size);
27 FuzzSkottieJSON(bytes);
28 return 0;
29}
30#endif