My favorites | Sign in
Project Home
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 31: Failed init results in memory leak
1 person starred this issue and may be notified of changes. Back to list
Status:  Duplicate
Owner:  ----
Closed:  Sep 2008


 
Reported by jheising, Sep 25, 2008
I create a CXMLDocument with standard syntax:

CXMLDocument* xmlDoc = [[CXMLDocument alloc] 
initWithXMLString:@"BadXMLString" options:1 << 10 error:&error];

If the XML String is bad, initWithXMLString returns a NULL object reference 
and xmlDoc is now equal to NULL. Now that xmlDoc is NULL there is no way to 
[xmlDoc release] the original [CXMLDocument alloc] and it results in a 
memory leak.

The only way to get around this is to create two objects:

CXMLDocument* xmlDocAlloc = [CXMLDocument alloc];
CXMLDocument* xmlDoc = [xmlDocAlloc initWithXMLString: ....... ];

if(xmlDoc == nil)
    [xmlDocAlloc release];




Sep 25, 2008
#1 jheising
Sorry about the multiple posts. Google was returning an error and I didn't know it 
was being submitted.
Sep 28, 2008
Project Member #2 jwight
Dupe.
Status: Duplicate

Powered by Google Project Hosting