Skip to content

Commit

Permalink
try fix use after free
Browse files Browse the repository at this point in the history
  • Loading branch information
sthalik committed Dec 23, 2023
1 parent 3659132 commit 519ae07
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions loader/error-tex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ 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 img = Trade::ImageData2D{PixelFormat::RGBA8Unorm, Vector2i(size), {}, std::as_const(array), {}, {}};
return img;
}

Expand Down
3 changes: 2 additions & 1 deletion loader/wall-atlas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const wall_info& loader_impl::make_invalid_wall_atlas()

constexpr auto name = "<invalid>"_s;
constexpr auto frame_size = Vector2ui{iTILE_SIZE.x(), iTILE_SIZE.z()};
auto tex = make_error_texture(frame_size);

auto a = std::make_shared<class wall_atlas>(
wall_atlas_def {
Expand All @@ -68,7 +69,7 @@ const wall_info& loader_impl::make_invalid_wall_atlas()
{{ {.index = 0, .count = 1, .pixel_size = frame_size, .is_defined = true, } } },
{{ {.val = 0}, {}, }},
{1u},
}, name, make_error_texture(frame_size));
}, name, std::move(tex));
invalid_wall_atlas = Pointer<wall_info>{InPlaceInit, wall_info{ .name = name, .atlas = std::move(a) } };
return *invalid_wall_atlas;
}
Expand Down

0 comments on commit 519ae07

Please sign in to comment.