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

Hard crash on STPColorUtils > perceivedBrightnessForColor #951

Closed
spencerkohan opened this issue May 29, 2018 · 1 comment
Closed

Hard crash on STPColorUtils > perceivedBrightnessForColor #951

spencerkohan opened this issue May 29, 2018 · 1 comment

Comments

@spencerkohan
Copy link

To make it easier to diagnose your issue, please fill out the following:

Summary

There's a hard crash from this method if the navigation bar color is UIColor.white:

  • (CGFloat)perceivedBrightnessForColor:(UIColor *)color {
    const CGFloat *component = CGColorGetComponents(color.CGColor);
    CGFloat brightness = ((component[0] * 299) + (component[1] * 587) + (component[2] * 114)) / 1000;
    return brightness;
    }

Basically if the color is defined using white/alpha rather than rgba, *component here will not have 3 values, and you get an exec bad acess

Code to reproduce

Just try calling this method with a nav bar with the tint color set to UIColor.white

iOS version

11

Installation method

cocoapods

SDK version

latest

@danj-stripe
Copy link
Contributor

Hi @spencerkohan,

Thanks for finding & reporting this! I had to turn on Address Sanitization before I saw the crash, but once I did it was 100% reproducible.

I've merged a fix, and it should go out in our next release.

Thanks!
Dan

jaimepark-stripe pushed a commit that referenced this issue Apr 11, 2022
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

2 participants