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

Fix attempt to subtract with overflow error in get_glyph_kern_advance #5

Merged
merged 1 commit into from
Dec 12, 2016

Conversation

mitchmindtree
Copy link
Contributor

@mitchmindtree mitchmindtree commented Nov 23, 2016

This fixes dylanede/rusttype#30 and PistonDevelopers/conrod#874.

Here's the equivalent line in the original C header. I wasn't 100% sure of the behaviour here, the operation basically seems to be this:

int a = (unsigned short)b - (int)c

After reading this SO post, it seems like b is converted to the result type int before the subtraction operation takes place? This even seems to be the case when doing int = (unsigned int) - (unsigned int);.

Anyways, I believe this PR changes the behaviour to more accurately represent the original C code behaviour and does seem to fix the bug when testing the aforementioned downstream issues.

@echochamber
Copy link

That is a really unobvious bug. Good job hunting it down @mitchmindtree

@dylanede dylanede merged commit 44432fa into redox-os:master Dec 12, 2016
@dylanede
Copy link
Contributor

Ah, thanks for this, merging! Sorry for the delay in getting to this.

@dylanede
Copy link
Contributor

I will push the changes to a new version on crates.io later today.

@andrewcsmith
Copy link

Reminder? I don't see it on crates.io but would like to use this fix.

@dylanede
Copy link
Contributor

@andrewcsmith Better late than never right? Done!

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