* Source/NSXMLNode.m (+_objectForNode:): Don't create a document

object for a private document.
* Tests/base/NSXMLNode/transfer.m: New code for test case
contributed by Doug Simons.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35026 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2012-04-04 21:39:12 +00:00
parent 3086ac94e6
commit 337118ee64
3 changed files with 41 additions and 1 deletions

View file

@ -3,6 +3,7 @@
#import <Foundation/NSXMLDocument.h>
#import <Foundation/NSXMLElement.h>
/*
int main()
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
@ -19,3 +20,34 @@ int main()
return 0;
}
*/
int main()
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSXMLDocument *doc;
NSXMLElement *elem;
NSXMLNode *child;
NSString *simpleXML = @"<num>6</num>";
doc = [[NSXMLDocument alloc] initWithXMLString: simpleXML
options: 0
error: NULL];
PASS(doc != nil, "document was initialized from a string");
// detach the root element from its document
elem = [doc rootElement];
// PASS_EQUAL([elem XMLString], simpleXML, "root element is correct");
[elem detach];
// now, simply accessing the text node child of the element leads to a CRASH
// when releasing the document
child = [elem childAtIndex: 0];
[doc release];
[arp release];
arp = nil;
return 0;
}