mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
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:
parent
8a5e513aff
commit
ae7e4ecf79
1 changed files with 17 additions and 10 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue