zzycami / touchcode

Automatically exported from code.google.com/p/touchcode
0 stars 0 forks source link

Memory Leak #32

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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];

Original issue reported on code.google.com by jheising on 25 Sep 2008 at 10:11

GoogleCodeExporter commented 8 years ago
Sorry about the multiple posts. Google was returning an error and I didn't know 
it 
was being submitted.

Original comment by jheising on 25 Sep 2008 at 10:25

GoogleCodeExporter commented 8 years ago
Dupe

Original comment by jwight on 28 Sep 2008 at 3:45