avoid crash in testcases

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@34921 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2012-03-11 15:04:36 +00:00
parent 6908b4724d
commit 765ad1d32c
2 changed files with 61 additions and 33 deletions

View file

@ -1,3 +1,9 @@
2012-03-11 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSXMLNode.m: Avoid crash when trying to get the parent of a
namespace ... namespaces don't have parents and in fact have a
completely different in-memory layout to other 'node' types.
2012-03-11 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSURLHandle.m:

View file

@ -31,6 +31,9 @@ GS_PRIVATE_INTERNAL(NSXMLNode)
#if defined(HAVE_LIBXML)
@interface NSXMLNamespaceNode : NSXMLNode
@end
static int
countAttributes(xmlNodePtr node)
{
@ -206,6 +209,22 @@ isEqualTree(xmlNodePtr nodeA, xmlNodePtr nodeB)
return NO;
}
/* FIXME ... the libxml2 data structure representing a namespace has a
* completely different layout from that of almost all other nodes, so
* the generix NSXMLNode code won't work and we need to override every
* method we use!
*/
@implementation NSXMLNamespaceNode
- (NSUInteger) level
{
return 0;
}
- (NSXMLNode*) parent
{
return nil;
}
@end
@implementation NSXMLNode (Private)
- (void *) _node
{
@ -1004,43 +1023,46 @@ execute_xpath(NSXMLNode *xmlNode, NSString *xpath_exp, NSString *nmspaces)
*/
switch (kind)
{
case NSXMLDocumentKind:
theSubclass = [NSXMLDocument class];
break;
case NSXMLDocumentKind:
theSubclass = [NSXMLDocument class];
break;
case NSXMLInvalidKind:
theSubclass = [NSXMLNode class];
break;
case NSXMLElementKind:
theSubclass = [NSXMLElement class];
break;
case NSXMLInvalidKind:
theSubclass = [NSXMLNode class];
break;
case NSXMLDTDKind:
theSubclass = [NSXMLDTD class];
break;
case NSXMLElementDeclarationKind:
case NSXMLEntityDeclarationKind:
case NSXMLNotationDeclarationKind:
theSubclass = [NSXMLDTDNode class];
break;
case NSXMLElementKind:
theSubclass = [NSXMLElement class];
break;
case NSXMLDTDKind:
theSubclass = [NSXMLDTD class];
break;
case NSXMLElementDeclarationKind:
case NSXMLEntityDeclarationKind:
case NSXMLNotationDeclarationKind:
theSubclass = [NSXMLDTDNode class];
break;
case NSXMLNamespaceKind:
theSubclass = [NSXMLNamespaceNode class];
break;
case NSXMLAttributeKind:
case NSXMLCommentKind:
case NSXMLNamespaceKind:
case NSXMLProcessingInstructionKind:
case NSXMLTextKind:
break;
case NSXMLAttributeKind:
case NSXMLCommentKind:
case NSXMLProcessingInstructionKind:
case NSXMLTextKind:
break;
case NSXMLAttributeDeclarationKind:
[self release];
return nil;
default:
kind = NSXMLInvalidKind;
theSubclass = [NSXMLNode class];
break;
case NSXMLAttributeDeclarationKind:
[self release];
return nil;
default:
kind = NSXMLInvalidKind;
theSubclass = [NSXMLNode class];
break;
}
/*