Kevin Lubick | 9eeede2 | 2018-05-03 16:26:10 -0400 | [diff] [blame] | 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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 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" |
Kevin Lubick | 9eeede2 | 2018-05-03 16:26:10 -0400 | [diff] [blame] | 13 | |
| 14 | void FuzzSkottieJSON(sk_sp<SkData> bytes) { |
Kevin Lubick | 9eeede2 | 2018-05-03 16:26:10 -0400 | [diff] [blame] | 15 | SkMemoryStream stream(bytes); |
Florin Malita | c83a0de | 2018-05-31 12:17:55 -0400 | [diff] [blame] | 16 | auto animation = skottie::Animation::Make(&stream); |
Kevin Lubick | 9eeede2 | 2018-05-03 16:26:10 -0400 | [diff] [blame] | 17 | if (!animation) { |
| 18 | return; |
| 19 | } |
Florin Malita | a33447d | 2018-05-29 13:46:54 -0400 | [diff] [blame] | 20 | animation->seek(0.1337f); // A "nothing up my sleeve" number |
Kevin Lubick | 9eeede2 | 2018-05-03 16:26:10 -0400 | [diff] [blame] | 21 | } |
| 22 | |
Kevin Lubick | 493f89e | 2020-09-14 08:37:35 -0400 | [diff] [blame] | 23 | #if defined(SK_BUILD_FOR_LIBFUZZER) |
Kevin Lubick | 9eeede2 | 2018-05-03 16:26:10 -0400 | [diff] [blame] | 24 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { |
Mike Klein | ea3f014 | 2019-03-20 11:12:10 -0500 | [diff] [blame] | 25 | gSkFontMgr_DefaultFactory = &ToolUtils::MakePortableFontMgr; |
Kevin Lubick | 9eeede2 | 2018-05-03 16:26:10 -0400 | [diff] [blame] | 26 | auto bytes = SkData::MakeWithoutCopy(data, size); |
| 27 | FuzzSkottieJSON(bytes); |
| 28 | return 0; |
| 29 | } |
| 30 | #endif |