blob: 30174bbf750843f2c6d9178f222f6ff66df8cc57 [file] [log] [blame]
Kevin Lubick2be14d32019-10-21 13:44:48 -04001/*
2 * Copyright 2019 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 "src/core/SkDescriptor.h"
9#include "src/core/SkRemoteGlyphCache.h"
10
11void FuzzSkDescriptorDeserialize(sk_sp<SkData> bytes) {
12 SkAutoDescriptor aDesc;
13 bool ok = SkFuzzDeserializeSkDescriptor(bytes, &aDesc);
14 if (!ok) {
15 return;
16 }
17
18 auto desc = aDesc.getDesc();
19
20 desc->computeChecksum();
21 desc->isValid();
22
23 // An arbitrary number
24 uint32_t tagToFind = 117;
25
26 uint32_t ignore;
27 desc->findEntry(tagToFind, &ignore);
28}
29
30#if defined(IS_FUZZING_WITH_LIBFUZZER)
31extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
Zepeng Hu5b35f212020-06-14 19:03:34 +000032 if (size > 1024) {
33 return 0;
34 }
Kevin Lubick2be14d32019-10-21 13:44:48 -040035 auto bytes = SkData::MakeWithoutCopy(data, size);
Kevin Lubicka12f6cb2019-10-23 07:53:29 -040036 FuzzSkDescriptorDeserialize(bytes);
Kevin Lubick2be14d32019-10-21 13:44:48 -040037 return 0;
38}
39#endif