1 // Copyright 2015 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include <stddef.h> 6 #include <stdint.h> 7 8 #include "base/compiler_specific.h" 9 #include "base/containers/span.h" 10 #include "base/logging.h" 11 #include "ui/base/resource/resource_scale_factor.h" 12 #include "ui/gfx/image/image.h" 13 14 struct Environment { EnvironmentEnvironment15 Environment() { 16 // Disable noisy logging. 17 logging::SetMinLogLevel(logging::LOGGING_FATAL); 18 } 19 }; 20 21 Environment* env = new Environment(); 22 23 // Entry point for LibFuzzer. LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)24extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 25 ui::SetSupportedResourceScaleFactors({ui::k100Percent}); 26 // SAFETY: `data` has length `size`, as guaranteed by the fuzzer API. 27 gfx::Image image = 28 gfx::Image::CreateFrom1xPNGBytes(UNSAFE_BUFFERS(base::span(data, size))); 29 if (image.IsEmpty()) { 30 return 0; 31 } 32 33 image.ToSkBitmap(); 34 return 0; 35 } 36