1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:47:45 +00:00

LibAccelGfx: Fix stack use after scope in GlyphAtlas::update()

This commit is contained in:
Aliaksandr Kalenik 2023-12-17 01:21:25 +01:00 committed by Andreas Kling
parent 36f0499cc8
commit 38d62563b3

View file

@ -45,8 +45,8 @@ void GlyphAtlas::update(HashMap<Gfx::Font const*, HashTable<u32>> const& unique_
glyphs_sorted_by_height.append(atlas_key); glyphs_sorted_by_height.append(atlas_key);
} }
quick_sort(glyphs_sorted_by_height, [&](auto const& a, auto const& b) { quick_sort(glyphs_sorted_by_height, [&](auto const& a, auto const& b) {
auto const& bitmap_a = *glyph_bitmaps.get(a); auto const* bitmap_a = *glyph_bitmaps.get(a);
auto const& bitmap_b = *glyph_bitmaps.get(b); auto const* bitmap_b = *glyph_bitmaps.get(b);
return bitmap_a->height() > bitmap_b->height(); return bitmap_a->height() > bitmap_b->height();
}); });
@ -56,7 +56,7 @@ void GlyphAtlas::update(HashMap<Gfx::Font const*, HashTable<u32>> const& unique_
int const texture_width = 512; int const texture_width = 512;
int const padding = 1; int const padding = 1;
for (auto const& glyphs_texture_key : glyphs_sorted_by_height) { for (auto const& glyphs_texture_key : glyphs_sorted_by_height) {
auto const& bitmap = *glyph_bitmaps.get(glyphs_texture_key); auto const* bitmap = *glyph_bitmaps.get(glyphs_texture_key);
if (current_x + bitmap->width() > texture_width) { if (current_x + bitmap->width() > texture_width) {
current_x = 0; current_x = 0;
current_y += row_height + padding; current_y += row_height + padding;