Search code examples
iphoneobjective-ctouchxml

TouchXML over release problem


I'm getting an EXEC_BAD_ACCESS error when I release a CXMLDocument.

Here's my very simple code which has no dependencies:

@implementation TestViewController

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];

    NSError *xmlError = nil;    
    CXMLDocument *xmlDoc = [[CXMLDocument alloc] initWithXMLString:@"<test></test>" options:0 error:&xmlError];
    CXMLElement *rootElement = [xmlDoc rootElement]; // Unused local variable   
    [xmlDoc release];
}

If I comment out CXMLElement *rootElement = [xmlDoc rootElement]; or if I retain it, there is no error.

How can calling [xmlDoc rootElement] cause xmlDoc to get over released? Is this a TouchXML bug or am I missing something really basic?

Similar question here, but no valid answers: Weird crash if I try to release CXMLDocument


Solution

  • The crash goes away when I turn Guard Malloc turned off. Assuming that Guard Malloc is reliable, this looks like it's a Touch XML bug.