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 | |
| 8 | #include "SkData.h" |
Kevin Lubick | ec1c620 | 2018-12-14 11:42:53 -0500 | [diff] [blame] | 9 | #include "SkFontMgrPriv.h" |
Kevin Lubick | 9eeede2 | 2018-05-03 16:26:10 -0400 | [diff] [blame] | 10 | #include "SkStream.h" |
Kevin Lubick | ec1c620 | 2018-12-14 11:42:53 -0500 | [diff] [blame] | 11 | #include "SkTestFontMgr.h" |
| 12 | #include "Skottie.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 | |
| 23 | #if defined(IS_FUZZING_WITH_LIBFUZZER) |
| 24 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { |
Kevin Lubick | ec1c620 | 2018-12-14 11:42:53 -0500 | [diff] [blame] | 25 | gSkFontMgr_DefaultFactory = &sk_tool_utils::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 |