FontDescription.LoadDescription throws NullReferenceException
Metalnem opened this issue · 1 comments
Metalnem commented
FontDescription.LoadDescription throws a NullReferenceException when loading the font from the attached archive. You can run the following code to reproduce it (the path variable should contain the path to the extracted file):
FontDescription.LoadDescription(path);
Found via SharpFuzz.
dlemstra commented
Full stackrace:
System.NullReferenceException : Object reference not set to an instance of an object.
NameTable.cs(31,0): at SixLabors.Fonts.Tables.General.NameTable.Load(BinaryReader reader)
at SixLabors.Fonts.Tables.General.NameTable.Load(FontReader reader)
at SixLabors.Fonts.Tables.TableLoader.Load[TTable](FontReader reader)
at SixLabors.Fonts.FontReader.GetTable[TTableType]()
at SixLabors.Fonts.FontDescription.LoadDescription(FontReader reader)
at SixLabors.Fonts.FontDescription.LoadDescription(String path)
reader.GetReaderAtTablePosition(TableName)
returns null
and we don't check this at several places. Wonder if we should change the code here to throw an exception when header
is null instead:
public virtual BinaryReader GetReaderAtTablePosition(string tableName)
{
TableHeader header = this.GetHeader(tableName);
return header?.CreateReader(this.stream);
}