From d93ef1ee0118b52452bd3c0452097433b9ee9e04 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 23 Dec 2023 13:07:44 +0100 Subject: fix use after free --- loader/error-tex.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/loader/error-tex.cpp b/loader/error-tex.cpp index 7f91f032..c3a0a58b 100644 --- a/loader/error-tex.cpp +++ b/loader/error-tex.cpp @@ -11,9 +11,14 @@ Trade::ImageData2D loader_impl::make_error_texture(Vector2ui size) { fm_assert(size.product() != 0); constexpr auto magenta = Vector4ub{255, 0, 255, 255}; - auto array = Array{DirectInit, size.product(), magenta}; - auto img = Trade::ImageData2D{PixelFormat::RGBA8Unorm, Vector2i(size), {}, - std::move(array), {}, {}}; + auto array = Array{NoInit, 4 * size.product()}; + auto data = array.data(), end = data + array.size(); + while (data != end) + { + *(Vector4ub*)data = magenta; + data += 4; + } + auto img = Trade::ImageData2D{PixelFormat::RGBA8Unorm, Vector2i(size), std::move(array)}; return img; } -- cgit v1.2.3