-
Notifications
You must be signed in to change notification settings - Fork 17.6k
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
x/image/font/sfnt: GlyphIndex panic after multiple calls without buffer #46948
Comments
/cc @nigeltao |
Can you attach the program (and ideally the .ttc file) too? |
I wrote a more minimalistic program that reproduces the problem: sfntpanic.zip |
I encountered this in the wild too and looked into it: when if b == nil {
b = &Buffer{}
} None of the other formats seem to be affected, as only format 4 is actually using the buffer. Might be a good idea to change the signatures of the other formats to |
Change https://go.dev/cl/398774 mentions this issue: |
Mostly for the panic fix on sfnt for golang/go#46948.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I am parsing a set of Roboto font files in a sequence. All of this occurs on a single thread/go routine (I ran it with
-race
just in case).When parsing each font file I am checking the bounds of the glyph
M
viafont.GlyphBounds
. In order to do that, I need to get the index of the glyph via thefont.GlyphIndex
method. I am passingnil
for buffer, which according to the documentation is allowed.On the 9th font to be processed, the application crashes with a
nil pointer dereference
.This does not reproduce itself if I pass a buffer object. Using a dedicated buffer per iteration or a shared buffer for all invocations works.
What did you expect to see?
What did you see instead?
The font files that I parse are as follows (where I have packed them in a Collection):
The text was updated successfully, but these errors were encountered: