Fix stack overflow.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@17453 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2003-08-07 18:22:03 +00:00
parent 6acd869d7b
commit 76b458f3e8
3 changed files with 132 additions and 126 deletions

View file

@ -3,7 +3,11 @@
* Source/NSString.m: nodeToObject() fix error in handling escape * Source/NSString.m: nodeToObject() fix error in handling escape
sequences in strings ... only treat a backslash specially when it sequences in strings ... only treat a backslash specially when it
is immediately followed by 'U' or 'u' and four hexadecimal digits. is immediately followed by 'U' or 'u' and four hexadecimal digits.
ensure data ia deallocated promptly.
* Source/GSCompatibility.m: match changes to property list escapes * Source/GSCompatibility.m: match changes to property list escapes
* Source/Additions/GSXML.m: change ownership policy so that nodes
are owned by theri parents, never by siblings ... prevent stack
overflow deallocating nodes in long documents.
* Tools/plist-0_9.dtd: document unicode escapes. * Tools/plist-0_9.dtd: document unicode escapes.
2003-08-02 Adam Fedor <fedor@gnu.org> 2003-08-02 Adam Fedor <fedor@gnu.org>

View file

@ -1340,7 +1340,7 @@ static NSMapTable *nodeNames = 0;
{ {
GSXMLNode *n = [GSXMLNode alloc]; GSXMLNode *n = [GSXMLNode alloc];
n = [n _initFrom: ((xmlNodePtr)(lib))->next parent: self]; n = [n _initFrom: ((xmlNodePtr)(lib))->next parent: _parent];
return AUTORELEASE(n); return AUTORELEASE(n);
} }
else else
@ -1367,7 +1367,7 @@ static NSMapTable *nodeNames = 0;
{ {
GSXMLNode *n = [GSXMLNode alloc]; GSXMLNode *n = [GSXMLNode alloc];
n = [n _initFrom: ptr parent: self]; n = [n _initFrom: ptr parent: _parent];
return AUTORELEASE(n); return AUTORELEASE(n);
} }
} }
@ -1476,7 +1476,7 @@ static NSMapTable *nodeNames = 0;
{ {
GSXMLNode *n = [GSXMLNode alloc]; GSXMLNode *n = [GSXMLNode alloc];
n = [n _initFrom: ((xmlNodePtr)(lib))->prev parent: self]; n = [n _initFrom: ((xmlNodePtr)(lib))->prev parent: _parent];
return AUTORELEASE(n); return AUTORELEASE(n);
} }
else else
@ -1501,7 +1501,7 @@ static NSMapTable *nodeNames = 0;
{ {
GSXMLNode *n = [GSXMLNode alloc]; GSXMLNode *n = [GSXMLNode alloc];
n = [n _initFrom: ptr parent: self]; n = [n _initFrom: ptr parent: _parent];
return AUTORELEASE(n); return AUTORELEASE(n);
} }
} }

View file

@ -46,6 +46,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "GNUstepBase/preface.h" #include "GNUstepBase/preface.h"
#include "Foundation/NSAutoreleasePool.h"
#include "Foundation/NSString.h" #include "Foundation/NSString.h"
#include "Foundation/NSCalendarDate.h" #include "Foundation/NSCalendarDate.h"
#include "Foundation/NSArray.h" #include "Foundation/NSArray.h"
@ -4987,16 +4988,17 @@ elementNode(GSXMLNode* node)
static id static id
nodeToObject(GSXMLNode* node) nodeToObject(GSXMLNode* node)
{
CREATE_AUTORELEASE_POOL(arp);
id result = nil;
node = elementNode(node);
if (node != nil)
{ {
NSString *name; NSString *name;
NSString *content; NSString *content;
GSXMLNode *children; GSXMLNode *children;
node = elementNode(node);
if (node == nil)
{
return nil;
}
name = [node name]; name = [node name];
children = [node firstChild]; children = [node firstChild];
content = [children content]; content = [children content];
@ -5070,15 +5072,15 @@ nodeToObject(GSXMLNode* node)
content = [NSString stringWithCharacters: buf length: len]; content = [NSString stringWithCharacters: buf length: len];
} }
} }
return content; result = content;
} }
else if ([name isEqualToString: @"true"]) else if ([name isEqualToString: @"true"])
{ {
return [NSNumber numberWithBool: YES]; result = [NSNumber numberWithBool: YES];
} }
else if ([name isEqualToString: @"false"]) else if ([name isEqualToString: @"false"])
{ {
return [NSNumber numberWithBool: NO]; result = [NSNumber numberWithBool: NO];
} }
else if ([name isEqualToString: @"integer"]) else if ([name isEqualToString: @"integer"])
{ {
@ -5086,7 +5088,7 @@ nodeToObject(GSXMLNode* node)
{ {
content = @"0"; content = @"0";
} }
return [NSNumber numberWithInt: [content intValue]]; result = [NSNumber numberWithInt: [content intValue]];
} }
else if ([name isEqualToString: @"real"]) else if ([name isEqualToString: @"real"])
{ {
@ -5094,7 +5096,7 @@ nodeToObject(GSXMLNode* node)
{ {
content = @"0.0"; content = @"0.0";
} }
return [NSNumber numberWithDouble: [content doubleValue]]; result = [NSNumber numberWithDouble: [content doubleValue]];
} }
else if ([name isEqualToString: @"date"]) else if ([name isEqualToString: @"date"])
{ {
@ -5102,12 +5104,12 @@ nodeToObject(GSXMLNode* node)
{ {
content = @""; content = @"";
} }
return [NSCalendarDate dateWithString: content result = [NSCalendarDate dateWithString: content
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"]; calendarFormat: @"%Y-%m-%d %H:%M:%S %z"];
} }
else if ([name isEqualToString: @"data"]) else if ([name isEqualToString: @"data"])
{ {
return [GSMimeDocument decodeBase64String: content]; result = [GSMimeDocument decodeBase64String: content];
} }
// container class // container class
else if ([name isEqualToString: @"array"]) else if ([name isEqualToString: @"array"])
@ -5120,9 +5122,9 @@ nodeToObject(GSXMLNode* node)
val = nodeToObject(children); val = nodeToObject(children);
[container addObject: val]; [container addObject: val];
children = elementNode([children next]); children = [children nextElement];
} }
return container; result = container;
} }
else if ([name isEqualToString: @"dict"]) else if ([name isEqualToString: @"dict"])
{ {
@ -5134,17 +5136,17 @@ nodeToObject(GSXMLNode* node)
id val; id val;
key = nodeToObject(children); key = nodeToObject(children);
children = elementNode([children next]); children = [children nextElement];
val = nodeToObject(children); val = nodeToObject(children);
children = elementNode([children next]); children = [children nextElement];
[container setObject: val forKey: key]; [container setObject: val forKey: key];
} }
return container; result = container;
} }
else
{
return nil;
} }
RETAIN(result);
RELEASE(arp);
return AUTORELEASE(result);
} }
#endif #endif