mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
fix crash that could happen looking up fallback
This commit is contained in:
@ -71,7 +71,7 @@ pub fn getOrAddGlyph(
|
|||||||
errdefer _ = self.glyphs.remove(glyphKey);
|
errdefer _ = self.glyphs.remove(glyphKey);
|
||||||
|
|
||||||
// Go through each familiy and look for a matching glyph
|
// Go through each familiy and look for a matching glyph
|
||||||
var fam_i: usize = 0;
|
var fam_i: ?usize = 0;
|
||||||
const glyph = glyph: {
|
const glyph = glyph: {
|
||||||
for (self.families.items) |*family, i| {
|
for (self.families.items) |*family, i| {
|
||||||
fam_i = i;
|
fam_i = i;
|
||||||
@ -97,13 +97,19 @@ pub fn getOrAddGlyph(
|
|||||||
|
|
||||||
// If we are regular, we use a fallback character
|
// If we are regular, we use a fallback character
|
||||||
log.warn("glyph not found, using fallback. codepoint={x}", .{utf32});
|
log.warn("glyph not found, using fallback. codepoint={x}", .{utf32});
|
||||||
fam_i = 0;
|
fam_i = null;
|
||||||
break :glyph try self.families.items[0].addGlyph(alloc, ' ', style);
|
break :glyph try self.families.items[0].addGlyph(alloc, ' ', style);
|
||||||
};
|
};
|
||||||
|
|
||||||
gop.value_ptr.* = fam_i;
|
// If we found a real value, then cache it.
|
||||||
|
// TODO: support caching fallbacks too
|
||||||
|
if (fam_i) |i|
|
||||||
|
gop.value_ptr.* = i
|
||||||
|
else
|
||||||
|
_ = self.glyphs.remove(glyphKey);
|
||||||
|
|
||||||
return GetOrAdd{
|
return GetOrAdd{
|
||||||
.family = fam_i,
|
.family = fam_i orelse 0,
|
||||||
.glyph = glyph,
|
.glyph = glyph,
|
||||||
|
|
||||||
// Technically possible that we found this in a cache...
|
// Technically possible that we found this in a cache...
|
||||||
|
Reference in New Issue
Block a user