New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FontDescription.LoadDescription throws NullReferenceException #97

Closed
Metalnem opened this Issue Dec 24, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@Metalnem
Copy link

Metalnem commented Dec 24, 2018

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

This comment has been minimized.

Copy link
Member

dlemstra commented Dec 24, 2018

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);
}

@dlemstra dlemstra referenced this issue Jan 5, 2019

Merged

Fix 97 #101

@tocsoft tocsoft closed this in 87d9d6a Jan 7, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment