yannickl / YLProgressBar

UIProgressView replacement with an highly and fully customizable animated progress bar in pure Core Graphics
http://yannickloriot.com/library/ios/ylprogressbar/
MIT License
1.28k stars 186 forks source link

AddressSanitizer: heap-buffer-overflow on address #58

Closed nickbit closed 6 years ago

nickbit commented 6 years ago

Hello Yannick,

After running my app through the AddressSanitizer I got a heap buffer overflow error. The lines causing that are in - (void)setProgressTintColor:(UIColor *)progressTintColor:

const CGFloat *c    = CGColorGetComponents(progressTintColor.CGColor);
UIColor *leftColor  = [UIColor colorWithRed:(c[0] / 2.0f) green:(c[1] / 2.0f) blue:(c[2] / 2.0f) alpha:(c[3])];

CGColorGetComponents is not guaranteed to return 4 components in all cases. In my case it returned 2 (color was white). To fix that, please replace the lines above with the following:

CGFloat red, green, blue, alpha;
[progressTintColor getRed:&red green:&green blue:&blue alpha:&alpha];
UIColor *leftColor  = [UIColor colorWithRed:(red / 2.0f) green:(green / 2.0f) blue:(blue / 2.0f) alpha:(alpha)];
yannickl commented 6 years ago

Thank you for the report! I'm going to fix that. 👍