diff --git a/ChangeLog b/ChangeLog index 8201762f9..65ae35b6c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-11-18 Richard Frith-Macdonald + + * 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 Notice: you should now use 'make DESTDIR=/tmp/xxx install' if you diff --git a/Source/Additions/GSXML.m b/Source/Additions/GSXML.m index 18a5baa28..539af032f 100644 --- a/Source/Additions/GSXML.m +++ b/Source/Additions/GSXML.m @@ -470,20 +470,27 @@ static NSMapTable *attrNames = 0; } /** - * Sets the root node of the document. + * Sets the root of the document.
+ * 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; } /** diff --git a/Source/GSHTTPURLHandle.m b/Source/GSHTTPURLHandle.m index f94c04d66..4aef5e5e5 100644 --- a/Source/GSHTTPURLHandle.m +++ b/Source/GSHTTPURLHandle.m @@ -734,8 +734,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data) [self backgroundLoadDidFailWithReason: @"Response parse failed"]; } - if (sock != nil - && (connectionState == reading || connectionState == idle)) + if (sock != nil && connectionState == reading) { if ([sock readInProgress] == NO) {