tinygo-org / tinyfont

Text library for TinyGo displays
https://tinygo.org
BSD 3-Clause "New" or "Revised" License
49 stars 12 forks source link

Fix a panic caused by out-of-range characters. #13

Closed iley closed 4 years ago

iley commented 4 years ago

Hi,

This fixes a panic triggered by unsupported characters.

The problem was that WriteLineRotated missed a range check before accessing font.Glyphs similar to the one in DrawCharRotated.

Here is the stacktrace I got:

panic: runtime error: index out of range [234] with length 95

goroutine 1 [running]:
tinygo.org/x/tinyfont.WriteLineRotated(0x3acc80, 0xb09090, 0x566c70, 0x14000d, 0x835eec, 0x8, 0x20, 0xffffffff, 0x0)
        /Users/ilya/projects/tinyapple/vendor/tinygo.org/x/tinyfont/tinyfont.go:86 +0x300
tinygo.org/x/tinyfont.WriteLine(...)
        /Users/ilya/projects/tinyapple/vendor/tinygo.org/x/tinyfont/tinyfont.go:77
main.main()
        /Users/ilya/projects/tinyapple/cmd/bot/main.go:69 +0x798

Please let me know if you need me to provide more info or make any further code changes. Thank you.

deadprogram commented 4 years ago

Hello @iley thank you for working on TinyFont. I changed the branch for this PR to dev which is where the work leading up to the next release is happening, and now there is a merge conflict. Can you please rebase your branch and resolve it?

Thank you!

iley commented 4 years ago

Hi @deadprogram. Thanks, I didn't know about the dev branch. I should have looked into your development process before sending this out! The code seems to differ significantly between master and dev so I'll first check if the issue reproduces at all on dev. If it does, I'll rebase and update the PR. Thank you for spending your time on this!

deadprogram commented 4 years ago

Hello @iley just wondering if you might have a moment to check if this is still valid? Thank you!

iley commented 4 years ago

@deadprogram I just built my program with dev branch and there's no issue. Looks like my PR is not relevant. Sorry for the delay! This slipped my mind somehow.

deadprogram commented 4 years ago

Thanks @iley for looking into it.