diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-12-23 13:07:44 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-12-23 14:09:36 +0100 |
commit | d93ef1ee0118b52452bd3c0452097433b9ee9e04 (patch) | |
tree | b363da84da7a3e01416434ab5c7e563dc1a6a99c | |
parent | 3659132ff075d23a87696a30ed87fe79e36053eb (diff) |
fix use after free
-rw-r--r-- | loader/error-tex.cpp | 11 |
1 files 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<Vector4ub>{DirectInit, size.product(), magenta}; - auto img = Trade::ImageData2D{PixelFormat::RGBA8Unorm, Vector2i(size), {}, - std::move(array), {}, {}}; + auto array = Array<char>{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; } |