title: Crash on _CFArrayGetValueAtIndex when calling CGPathRelease on CGPath object
body: <p>I'm getting a crash that I am completely stumped on, when releasing a CGPath object. The crash is occurring in the <a href="https://github.com/jasarien/CoreTextHyperlinkView" rel="nofollow">CoreTextHyperlinkView</a> library at the end of the <code>- (void)drawInContext:(CGContextRef)ctx bounds:(CGRect)bounds</code> method in the <code>JSCoreTextView</code> class.</p>
  
  <p>Basically it's using Core Graphics/Text to draw underlined text. It creates a path, draws it, then releases it.</p>
  
  <p>Here is the relevant stack trace:</p>
  
  <pre><code>Thread 0 Crashed:
  0   CoreFoundation                      0x319058b6 _CFArrayGetValueAtIndex + 2
  1   MyApp                               0x00300891 -[JSCoreTextView drawInContext:bounds:] (JSCoreTextView.m:678)
  2   MyApp                               0x00300c5f -[JSCoreTextView drawRect:] (JSCoreTextView.m:709)
  3   UIKit                               0x337ded61 -[UIView(CALayerDelegate) drawLayer:inContext:] + 365
  4   QuartzCore                          0x3358f315 -[CALayer drawInContext:] + 113
  5   QuartzCore                          0x3358e8c3 CABackingStoreUpdate_ + 1779
  6   QuartzCore                          0x3358e037 CA::Layer::display_() + 975
  7   QuartzCore                          0x335850b7 CA::Layer::display_if_needed(CA::Transaction*) + 203
  8   QuartzCore                          0x33584fe1 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 25
  9   QuartzCore                          0x335849c3 CA::Context::commit_transaction(CA::Transaction*) + 239
  10  QuartzCore                          0x335847d5 CA::Transaction::commit() + 317
  11  QuartzCore                          0x33584639 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 61
  12  CoreFoundation                      0x3199b941 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 21
  13  CoreFoundation                      0x31999c39 __CFRunLoopDoObservers + 277
  14  CoreFoundation                      0x31999f93 __CFRunLoopRun + 747
  15  CoreFoundation                      0x3190d23d _CFRunLoopRunSpecific + 357
  16  CoreFoundation                      0x3190d0c9 _CFRunLoopRunInMode + 105
  17  GraphicsServices                    0x354ec33b _GSEventRunModal + 75
  18  UIKit                               0x338292b9 _UIApplicationMain + 1121
  19  MyApp                               0x0003fad7 main (main.m:13) 
  </code></pre>
  
  <p>It seems like some array internal the the CGPath is causing the problem. Could this just be a Core Text or Core Graphics bug in iOS? I'm stuck as to how to go about investigating further as I can't look into the source code of the iOS SDK.</p>
  
  <p>We only use this view in a modified <a href="https://github.com/gpambrozio/BlockAlertsAnd-ActionSheets" rel="nofollow">BlockAlertView</a> like this below example. We're getting the text from our JSON API in either english or arabic, which may contain email addresses or URLs to be underlineed and linkified.</p>
  
  <pre><code>JSCoreTextView *coreTextView = [[JSCoreTextView alloc] initWithFrame:CGRectMake(kAlertViewBorder, _height, frame.size.width-kAlertViewBorder*2, size.height)];
  coreTextView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
  coreTextView.delegate = self;
  coreTextView.text = message;
  coreTextView.textColor = _messageColor;
  coreTextView.textAlignment = kCTCenterTextAlignment;
  coreTextView.fontName = _messageFont.fontName;
  coreTextView.fontSize = _messageFont.pointSize;
  coreTextView.linkColor = _messageColor;
  coreTextView.highlightedLinkColor = _messageLinkColor;
  coreTextView.highlightColor = _messageColor;
  coreTextView.backgroundColor = UIColor.clearColor;
  coreTextView.underlined = YES;           
  [_view addSubview:coreTextView];
  </code></pre>