MBCoverFlowView icon indicating copy to clipboard operation
MBCoverFlowView copied to clipboard

fmax use in MBCoverFlow

Open peternlewis opened this issue 6 years ago • 0 comments

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.

peternlewis avatar Mar 26 '18 04:03 peternlewis