check argument to setRootNode: and avoid unnecessary read on http connection.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@24125 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2006-11-18 08:03:05 +00:00
parent 0a715d987a
commit 52a473a8cc
3 changed files with 25 additions and 12 deletions

View file

@ -1,3 +1,10 @@
2006-11-18 Richard Frith-Macdonald <rfm@gnu.org>
* Source/Additions/GSXML.m: ([setRootNode:]) Add checks for invalid
argument and improve documentation.
* Source/GSHTTPURLHandle.m: don't keep unecessary read operation in
progress on idle connection.
2006-11-15 Nicola Pero <nicola.pero@meta-innovation.com> 2006-11-15 Nicola Pero <nicola.pero@meta-innovation.com>
Notice: you should now use 'make DESTDIR=/tmp/xxx install' if you Notice: you should now use 'make DESTDIR=/tmp/xxx install' if you

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 - (GSXMLNode*) setRoot: (GSXMLNode*)node
{ {
void *nodeLib = [node lib]; xmlNodePtr nodeLib = (xmlNodePtr)[node lib];
void *oldRoot = xmlDocSetRootElement(lib, nodeLib); xmlNodePtr selfLib = (xmlNodePtr)[self lib];
GSXMLNode *n;
if (oldRoot == NULL) if (node == nil)
return nil; {
[NSException raise: NSInvalidArgumentException
n = [GSXMLNode alloc]; format: @"Attempt to set root of document to nil"];
n = [n _initFrom: nodeLib parent: self]; }
return AUTORELEASE(n); if (nodeLib->doc != selfLib->doc)
{
[NSException raise: NSInvalidArgumentException
format: @"Attempt to set root to node from other document"];
}
xmlDocSetRootElement(lib, nodeLib);
return node;
} }
/** /**

View file

@ -734,8 +734,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
[self backgroundLoadDidFailWithReason: @"Response parse failed"]; [self backgroundLoadDidFailWithReason: @"Response parse failed"];
} }
if (sock != nil if (sock != nil && connectionState == reading)
&& (connectionState == reading || connectionState == idle))
{ {
if ([sock readInProgress] == NO) if ([sock readInProgress] == NO)
{ {