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

fmax use in MBCoverFlow #4

Open
peternlewis opened this issue Mar 26, 2018 · 0 comments
Open

fmax use in MBCoverFlow #4

peternlewis opened this issue Mar 26, 2018 · 0 comments

Comments

@peternlewis
Copy link

There is a subtle bug in this line:

[_scroller setNumberOfIncrements:fmax([self.content count]-1, 0)];

Namely, the count method returns an unsigned long (NSUInteger), and therefore when count is 0, and you subtract 1, you get an overflow. This can be fixed easily enough by casting to a signed integer:

[_scroller setNumberOfIncrements:fmax(((NSInteger)[self.content count])-1, 0)];

And yes, nine years on I am still using this code in Keyboard Maestro.

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

1 participant