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 ArgumentException #96

Closed
Metalnem opened this issue Dec 24, 2018 · 5 comments
Closed

FontDescription.LoadDescription throws ArgumentException #96

Metalnem opened this issue Dec 24, 2018 · 5 comments

Comments

@Metalnem
Copy link

FontDescription.LoadDescription throws an ArgumentException 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

The full exception is:

System.ArgumentException : An item with the same key has already been added. Key: kern
Stack Trace:
  at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
  at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
  at SixLabors.Fonts.FontReader..ctor(Stream stream, TableLoader loader)
  at SixLabors.Fonts.FontReader..ctor(Stream stream)
  at SixLabors.Fonts.FontDescription.LoadDescription(String path)

Okay if I add a patch that does headers[tbl.Tag] instead of headers.Add(tbl.Tag) @tocsoft?

@tocsoft
Copy link
Member

tocsoft commented Dec 24, 2018

no real problem, not sure its a valid font file with duplicate tables but preventing it breaking with an unhelpful error is better

@Metalnem
Copy link
Author

Not a valid font - it was obtained by fuzzing the library. The fuzzer started with a small valid font and generated thousands of random mutations before generating this particular one.

@dlemstra
Copy link
Member

dlemstra commented Dec 24, 2018

@tocsoft What would you prefer that we do if we find a duplicate table? Don't understand your answer 😉

@tocsoft
Copy link
Member

tocsoft commented Dec 24, 2018

Just replace the previous entry for now like you suggested. We can worry about correctness later as I can't currently find anything saying it's invalid to have duplicate tables defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants