mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 08:58:11 +00:00
Lagom: Make BMP fuzzer look like the other image loader fuzzers
This commit is contained in:
parent
4f12efe191
commit
ec4c2f971b
3 changed files with 10 additions and 9 deletions
|
@ -186,6 +186,14 @@ RefPtr<Gfx::Bitmap> load_bmp(const StringView& path)
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RefPtr<Gfx::Bitmap> load_bmp_from_memory(const u8* data, size_t length)
|
||||||
|
{
|
||||||
|
auto bitmap = load_bmp_impl(data, length);
|
||||||
|
if (bitmap)
|
||||||
|
bitmap->set_mmap_name(String::format("Gfx::Bitmap [%dx%d] - Decoded BMP: <memory>", bitmap->width(), bitmap->height()));
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
static const LogStream& operator<<(const LogStream& out, Endpoint<i32> ep)
|
static const LogStream& operator<<(const LogStream& out, Endpoint<i32> ep)
|
||||||
{
|
{
|
||||||
return out << "(" << ep.x << ", " << ep.y << ", " << ep.z << ")";
|
return out << "(" << ep.x << ", " << ep.y << ", " << ep.z << ")";
|
||||||
|
|
|
@ -26,13 +26,13 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/Vector.h>
|
|
||||||
#include <LibGfx/Bitmap.h>
|
#include <LibGfx/Bitmap.h>
|
||||||
#include <LibGfx/ImageDecoder.h>
|
#include <LibGfx/ImageDecoder.h>
|
||||||
|
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
|
||||||
RefPtr<Gfx::Bitmap> load_bmp(const StringView& path);
|
RefPtr<Gfx::Bitmap> load_bmp(const StringView& path);
|
||||||
|
RefPtr<Gfx::Bitmap> load_bmp_from_memory(const u8*, size_t);
|
||||||
|
|
||||||
struct BMPLoadingContext;
|
struct BMPLoadingContext;
|
||||||
|
|
||||||
|
|
|
@ -29,13 +29,6 @@
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||||
{
|
{
|
||||||
Gfx::BMPImageDecoderPlugin loader { data, size };
|
Gfx::load_bmp_from_memory(data, size);
|
||||||
auto bitmap = loader.bitmap();
|
|
||||||
if (!bitmap)
|
|
||||||
return 1;
|
|
||||||
if (bitmap->width() >= 100000 || bitmap->height() >= 100000) {
|
|
||||||
fprintf(stderr, "Silly bitmap: %dx%d pixels?!\n", bitmap->width(), bitmap->height());
|
|
||||||
ASSERT_NOT_REACHED();
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue