Skip to content
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
Closed

FontDescription.LoadDescription throws NullReferenceException #97

Metalnem opened this issue Dec 24, 2018 · 1 comment

Comments

@Metalnem
Copy link

@Metalnem 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
Copy link
Member

@dlemstra 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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants