diff options
-rw-r--r-- | Libraries/LibGfx/BMPLoader.cpp | 8 | ||||
-rw-r--r-- | Libraries/LibGfx/BMPLoader.h | 2 | ||||
-rw-r--r-- | Meta/Lagom/Fuzzers/FuzzBMP.cpp | 9 |
3 files changed, 10 insertions, 9 deletions
diff --git a/Libraries/LibGfx/BMPLoader.cpp b/Libraries/LibGfx/BMPLoader.cpp index 0918335b3a..c746e694ea 100644 --- a/Libraries/LibGfx/BMPLoader.cpp +++ b/Libraries/LibGfx/BMPLoader.cpp @@ -186,6 +186,14 @@ RefPtr<Gfx::Bitmap> load_bmp(const StringView& path) 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) { return out << "(" << ep.x << ", " << ep.y << ", " << ep.z << ")"; diff --git a/Libraries/LibGfx/BMPLoader.h b/Libraries/LibGfx/BMPLoader.h index 6493b196ea..92f54e6b5f 100644 --- a/Libraries/LibGfx/BMPLoader.h +++ b/Libraries/LibGfx/BMPLoader.h @@ -26,13 +26,13 @@ #pragma once -#include <AK/Vector.h> #include <LibGfx/Bitmap.h> #include <LibGfx/ImageDecoder.h> namespace Gfx { RefPtr<Gfx::Bitmap> load_bmp(const StringView& path); +RefPtr<Gfx::Bitmap> load_bmp_from_memory(const u8*, size_t); struct BMPLoadingContext; diff --git a/Meta/Lagom/Fuzzers/FuzzBMP.cpp b/Meta/Lagom/Fuzzers/FuzzBMP.cpp index 40ebd22784..4cb9eac919 100644 --- a/Meta/Lagom/Fuzzers/FuzzBMP.cpp +++ b/Meta/Lagom/Fuzzers/FuzzBMP.cpp @@ -29,13 +29,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - Gfx::BMPImageDecoderPlugin loader { 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(); - } + Gfx::load_bmp_from_memory(data, size); return 0; } |