title: libxml2 on iOS causing EXC_BAD_ACCESS errors when parsing HTML with HTMLParser
body: <p>I've been working on a project that uses libxml2 HTMLParser module to parse webpage HTML on iOS. I'm getting an EXC_BAD_ACCESS error from libxml2's htmlParseDocument whenever I try to parse a webpage that contains the line:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  </code></pre>
  
  <p>If I strip this line out of the HTML, parsing works perfectly.</p>
  
  <p>Also note, I am using the DTHTMLParser class to bind the libxml2 SAX callbacks to Objective-C code.</p>
  
  <p>Since EXC_BAD_ACCESS in htmlParseDocument isn't much to go on, I've built a sample Xcode project that reproduces the error. I made it in Xcode 4.4 on Mountain Lion targeted for iOS 5.1. First it parses an HTML file that doesn't contain the offending line, then it attempts to parse the document with the offending line and crashes. You can download it here: <a href="http://michaelmanesh.com/code/libxml2-crash.zip" rel="nofollow">http://michaelmanesh.com/code/libxml2-crash.zip</a></p>