iOS9 Heap Buffer Overflow Detected - CGContextSetFillColor

644 Views Asked by At

I've got a custom drawRect: function where I'm drawing to the context. At two different points I've been hitting "Heap buffer overflow detected". The two lines of code are:

CGContextSetFillColor(context, CGColorGetComponents(self.myColor.CGColor));
CGContextSetStrokeColor(context, CGColorGetComponents(self.myColor.CGColor));

It seems like any time a color is referenced by a CGContext method, the Heap Buffer Overflow is detected. The oddity that I've been able to track down is the type of UIColor object that is being used. Whenever the UIColor is of type "UIDeviceWhiteColorSpace" this crash happens. Whenever the UIColor is of type "UIDeviceRGBColorSpace" this crash does not occur.

Examples of colors that produce the "UIDeviceWhiteColorSpace" color type are:

[UIColor clearColor]
[UIColor whiteColor]
[UIColor lightGrayColor]

For now, I have a work around to generate 'clear', 'white', and 'light gray' colors from HEX values, my HEX method only producing UIColor of type "UIDeviceRGBColorSpace".

This code has run fine on iOS7 and iOS8 for a while now.

Ultimately my question is: are other people experiencing this? Any other known work arounds? Can we expect this to continue into the iOS 9 GM?

0

There are 0 best solutions below