Backport argument checking bugfix

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/branches/base-1_13_0@24126 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2006-11-18 08:05:58 +00:00
parent 8a5e513aff
commit ae7e4ecf79

View file

@ -470,20 +470,27 @@ static NSMapTable *attrNames = 0;
}
/**
* Sets the root node of the document.
* Sets the root of the document.<br />
* NB. The node must have been created as part of the receiving document
* (eg. using the -makeNodeWithNamespace:name:content: method).
*/
- (GSXMLNode*) setRoot: (GSXMLNode*)node
{
void *nodeLib = [node lib];
void *oldRoot = xmlDocSetRootElement(lib, nodeLib);
GSXMLNode *n;
xmlNodePtr nodeLib = (xmlNodePtr)[node lib];
xmlNodePtr selfLib = (xmlNodePtr)[self lib];
if (oldRoot == NULL)
return nil;
n = [GSXMLNode alloc];
n = [n _initFrom: nodeLib parent: self];
return AUTORELEASE(n);
if (node == nil)
{
[NSException raise: NSInvalidArgumentException
format: @"Attempt to set root of document to nil"];
}
if (nodeLib->doc != selfLib->doc)
{
[NSException raise: NSInvalidArgumentException
format: @"Attempt to set root to node from other document"];
}
xmlDocSetRootElement(lib, nodeLib);
return node;
}
/**