1 /* 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 FuzzSkDescriptorDeserialize(sk_sp<SkData> bytes)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(SK_BUILD_FOR_LIBFUZZER) LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)31extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { 32 if (size > 1024) { 33 return 0; 34 } 35 auto bytes = SkData::MakeWithoutCopy(data, size); 36 FuzzSkDescriptorDeserialize(bytes); 37 return 0; 38 } 39 #endif 40