fix: fix Font Preview crash if opened manually
This commit is contained in:
@@ -124,7 +124,10 @@ struct TrueTypeFont {
|
||||
montauk::read(fd, data, 0, size);
|
||||
montauk::close(fd);
|
||||
|
||||
if (!stbtt_InitFont(&info, data, stbtt_GetFontOffsetForIndex(data, 0))) {
|
||||
// stbtt_GetFontOffsetForIndex returns -1 for non-font data; passing
|
||||
// that into stbtt_InitFont makes it dereference data + (uint32)-1.
|
||||
int off = stbtt_GetFontOffsetForIndex(data, 0);
|
||||
if (off < 0 || !stbtt_InitFont(&info, data, off)) {
|
||||
montauk::free(data);
|
||||
data = nullptr;
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user