Skip to content

fmax use in MBCoverFlow #4

@peternlewis

Description

@peternlewis

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions