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

Comments

Projects
None yet
3 participants
@Metalnem
Copy link

Metalnem commented Dec 24, 2018

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

This comment has been minimized.

Copy link
Member

dlemstra commented Dec 24, 2018

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

This comment has been minimized.

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

This comment has been minimized.

Copy link

Metalnem commented Dec 24, 2018

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

This comment has been minimized.

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

This comment has been minimized.

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.

@dlemstra dlemstra referenced this issue Dec 25, 2018

Merged

Fix 96 #98

@tocsoft tocsoft closed this Dec 26, 2018

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