AddressSanitizer: heap-buffer-overflow UIColor+KVNContrast.m:16 in -[UIColor(KVNContrast) statusBarStyleConstrastStyle]
Opened this issue · 0 comments
andriy-appuchino commented
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;