Skip to content

Commit 3a17c50

Browse files
committed
More super init fixes
1 parent d58950a commit 3a17c50

1 file changed

Lines changed: 56 additions & 40 deletions

File tree

Source/Additions/GSXML.m

Lines changed: 56 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -635,10 +635,13 @@ - (id) _initFrom: (void*)data parent: (id)p ownsLib: (BOOL)f
635635
DESTROY(self);
636636
return nil;
637637
}
638-
lib = data;
639-
_ownsLib = f;
640-
((xmlNodePtr)(lib))->_private = self;
641-
ASSIGN(_parent, p);
638+
if (nil != (self = [super init]))
639+
{
640+
lib = data;
641+
_ownsLib = f;
642+
((xmlNodePtr)(lib))->_private = self;
643+
ASSIGN(_parent, p);
644+
}
642645
return self;
643646
}
644647
@end
@@ -1690,15 +1693,18 @@ @implementation GSXMLNode (GSPrivate)
16901693
*/
16911694
- (id) _initFrom: (void*)data parent: (id)p
16921695
{
1693-
if (data == NULL)
1696+
if (nil != (self = [super init]))
16941697
{
1695-
NSLog(@"%@ - no data for initialization",
1696-
NSStringFromClass([self class]));
1697-
DESTROY(self);
1698-
return nil;
1698+
if (data == NULL)
1699+
{
1700+
NSLog(@"%@ - no data for initialization",
1701+
NSStringFromClass([self class]));
1702+
DESTROY(self);
1703+
return nil;
1704+
}
1705+
lib = data;
1706+
ASSIGN(_parent, p);
16991707
}
1700-
lib = data;
1701-
ASSIGN(_parent, p);
17021708
return self;
17031709
}
17041710
- (void) _setOwnsLib: (BOOL)f
@@ -2082,25 +2088,28 @@ - (id) init
20822088
*/
20832089
- (id) initWithSAXHandler: (GSSAXHandler*)handler
20842090
{
2085-
if (handler == nil)
2086-
{
2087-
saxHandler = [GSTreeSAXHandler new];
2088-
}
2089-
else if ([handler isKindOfClass: [GSSAXHandler class]] == YES)
2090-
{
2091-
saxHandler = RETAIN(handler);
2092-
}
2093-
else
2094-
{
2095-
NSLog(@"Bad GSSAXHandler object passed to GSXMLParser initialiser");
2096-
DESTROY(self);
2097-
return nil;
2098-
}
2099-
[saxHandler _setParser: self];
2100-
if ([self _initLibXML] == NO)
2091+
if (nil != (self = [super init]))
21012092
{
2102-
DESTROY(self);
2103-
return nil;
2093+
if (handler == nil)
2094+
{
2095+
saxHandler = [GSTreeSAXHandler new];
2096+
}
2097+
else if ([handler isKindOfClass: [GSSAXHandler class]] == YES)
2098+
{
2099+
saxHandler = RETAIN(handler);
2100+
}
2101+
else
2102+
{
2103+
NSLog(@"Bad GSSAXHandler object passed to GSXMLParser initialiser");
2104+
DESTROY(self);
2105+
return nil;
2106+
}
2107+
[saxHandler _setParser: self];
2108+
if ([self _initLibXML] == NO)
2109+
{
2110+
DESTROY(self);
2111+
return nil;
2112+
}
21042113
}
21052114
return self;
21062115
}
@@ -2181,8 +2190,10 @@ - (id) initWithSAXHandler: (GSSAXHandler*)handler
21812190
DESTROY(self);
21822191
return nil;
21832192
}
2184-
src = [data copy];
2185-
self = [self initWithSAXHandler: handler];
2193+
if (nil != (self = [self initWithSAXHandler: handler]))
2194+
{
2195+
src = [data copy];
2196+
}
21862197
return self;
21872198
}
21882199

@@ -3976,11 +3987,14 @@ - (id) init
39763987
- (id) _initWithNativePointer: (xmlXPathObject *)lib
39773988
context: (GSXPathContext *)context
39783989
{
3979-
_lib = lib;
3980-
/* We RETAIN our context because we might be holding references to nodes
3981-
* which belong to the document, and we must make sure the document is
3982-
* not freed before we are. */
3983-
ASSIGN (_context, context);
3990+
if (nil != (self = [super init]))
3991+
{
3992+
_lib = lib;
3993+
/* We RETAIN our context because we might be holding references to nodes
3994+
* which belong to the document, and we must make sure the document is
3995+
* not freed before we are. */
3996+
ASSIGN (_context, context);
3997+
}
39843998
return self;
39853999
}
39864000

@@ -4165,10 +4179,12 @@ @implementation GSXPathContext
41654179
*/
41664180
- (id) initWithDocument: (GSXMLDocument *)d
41674181
{
4168-
ASSIGN (_document, d);
4169-
_lib = xmlXPathNewContext ([_document lib]);
4170-
((xmlXPathContext*)_lib)->node = xmlDocGetRootElement ([_document lib]);
4171-
4182+
if (nil != (self = [super init]))
4183+
{
4184+
ASSIGN (_document, d);
4185+
_lib = xmlXPathNewContext ([_document lib]);
4186+
((xmlXPathContext*)_lib)->node = xmlDocGetRootElement ([_document lib]);
4187+
}
41724188
return self;
41734189
}
41744190

0 commit comments

Comments
 (0)