yannickl/YLProgressBar

Ensure that `stripesWidth` is not set to zero to prevent memory allocation issues

Closed this issue · 1 comments

If you accidentally set stripesWidth to 0, then in the following piece of code in the drawStripes:(CGContextRef)context withRect:(CGRect)rect method in YLProgressBar.m

NSInteger start = -_stripesWidth;
    NSInteger end   = rect.size.width / (2 * _stripesWidth) + (2 * _stripesWidth);
    CGFloat yOffset = (_type == YLProgressBarTypeRounded) ? YLProgressBarSizeInset : 0;

    for (NSInteger i = start; i <= end; i++)
    {
        UIBezierPath *stripe = [self stripeWithOrigin:CGPointMake(i * 2 * _stripesWidth + _stripesOffset, yOffset)
                                               bounds:rect
                                          orientation:_stripesOrientation];
        [allStripes appendPath:stripe];
    }

will result in the allocation of 2147483647 UIBezierPath objects, because end will evaluate to 2147483647

Hi,

Thank you for the hint!

Best