* 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:
fredkiefer 2012-04-04 21:39:12 +00:00
parent e478c41574
commit 7fd8c5e1ce
3 changed files with 41 additions and 1 deletions

View file

@ -1,3 +1,10 @@
2012-04-04 Fred Kiefer <FredKiefer@gmx.de>
* 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.
2012-04-03 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSXMLElement.m,

View file

@ -416,7 +416,8 @@ isEqualTree(xmlNodePtr nodeA, xmlNodePtr nodeB)
docNode = node->doc;
}
if ((docNode != NULL) && ((xmlNodePtr)docNode != node))
if ((docNode != NULL) && ((xmlNodePtr)docNode != node) &&
(NULL != docNode->children))
{
doc = (NSXMLDocument*)[self _objectForNode: (xmlNodePtr)docNode];
if (doc != nil)

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;
}