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

AddressSanitizer: heap-buffer-overflow UIColor+KVNContrast.m:16 in -[UIColor(KVNContrast) statusBarStyleConstrastStyle] #123

Open
andriy-appuchino opened this issue Jul 20, 2020 · 0 comments

Comments

@andriy-appuchino
Copy link

andriy-appuchino commented Jul 20, 2020

After running my app through the AddressSanitizer I got a heap buffer overflow error.
The lines causing that are in UIColor+KVNContrast.h extension in - (UIStatusBarStyle)statusBarStyleConstrastStyle.

	const CGFloat *componentColors = CGColorGetComponents(self.CGColor);
	CGFloat darknessScore = (((componentColors[0] * 255) * 299) + ((componentColors[1] * 255) * 587) + ((componentColors[2] * 255) * 114)) / 1000;

CGColorGetComponents is not guaranteed to return 3 components in all cases.
To fix that, please replace the lines above with the following:

	CGFloat red, green, blue;
	[self getRed:&red green:&green blue:&blue alpha:nil];
	CGFloat darknessScore = (((red * 255) * 299) + ((green * 255) * 587) + ((blue * 255) * 114)) / 1000;
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