From 32cc53a901b24a683787d3417fd635fa06a278b6 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Tue, 19 Dec 2017 23:53:32 +0100 Subject: Fix stack-overflow when creating a new atlas When an atlas is full and the `insert` call fails, a new atlas should be created. This is the current strategy, however the atlas is put at the end of the vector, but the `current_atlas` index is set to 0, instead of the last element. This leads to a recursion where it keeps trying to insert into the full atlas at position 0 instead of the new at `atlas.len() - 1`. With this simple fix a stack-overflow is prevented because the new atlas is inserted as the first element, which then will be used correctly for loading new glyphs. This fixes jwilm/alacritty/issues/842 and might also solve jwilm/alacritty/issues/914 (I wasn't able to reproduce this with the latest master). --- src/renderer/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/renderer/mod.rs') diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs index 237c8416..e6d33c9b 100644 --- a/src/renderer/mod.rs +++ b/src/renderer/mod.rs @@ -876,7 +876,7 @@ impl<'a> LoadGlyph for LoaderApi<'a> { let atlas = Atlas::new(ATLAS_SIZE); *self.active_tex = 0; // Atlas::new binds a texture. Ugh this is sloppy. *self.current_atlas = 0; - self.atlas.push(atlas); + self.atlas.insert(0, atlas); self.load_glyph(rasterized) } } -- cgit v1.2.3-54-g00ecf