Protected all initXXX methods so that for empty input nil will be

returned.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@11098 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
FredKiefer 2001-10-06 22:30:54 +00:00
parent 9bdd7027a3
commit 4fbe4469d1

View file

@ -561,6 +561,12 @@ static Class converter_class(NSString *format, BOOL producer)
// FIXME: This expects the file to be RTFD
NSFileWrapper *fw;
if (path == nil)
{
RELEASE (self);
return nil;
}
fw = [[NSFileWrapper alloc] initWithPath: path];
AUTORELEASE (fw);
@ -572,6 +578,13 @@ documentAttributes: (NSDictionary **)dict
{
NSData *data = [url resourceDataUsingCache: YES];
if (data == nil)
{
RELEASE (self);
return nil;
}
// FIXME: This expects the URL to point to a HTML page
return [self initWithHTML: data
baseURL: [url baseURL]
@ -581,7 +594,15 @@ documentAttributes: (NSDictionary **)dict
- (id) initWithRTFDFileWrapper: (NSFileWrapper *)wrapper
documentAttributes: (NSDictionary **)dict
{
NSAttributedString *new = [converter_class(@"RTFD", NO)
NSAttributedString *new;
if (wrapper == nil)
{
RELEASE (self);
return nil;
}
new = [converter_class(@"RTFD", NO)
parseFile: wrapper
documentAttributes: dict];
// We do not return self but the newly created object
@ -592,7 +613,15 @@ documentAttributes: (NSDictionary **)dict
- (id) initWithRTFD: (NSData*)data
documentAttributes: (NSDictionary**)dict
{
NSAttributedString *new = [converter_class(@"RTFD", NO)
NSAttributedString *new;
if (data == nil)
{
RELEASE (self);
return nil;
}
new = [converter_class(@"RTFD", NO)
parseData: data
documentAttributes: dict];
// We do not return self but the newly created object
@ -603,7 +632,15 @@ documentAttributes: (NSDictionary **)dict
- (id) initWithRTF: (NSData *)data
documentAttributes: (NSDictionary **)dict
{
NSAttributedString *new = [converter_class(@"RTF", NO)
NSAttributedString *new;
if (data == nil)
{
RELEASE (self);
return nil;
}
new = [converter_class(@"RTF", NO)
parseData: data
documentAttributes: dict];
// We do not return self but the newly created object
@ -623,6 +660,12 @@ documentAttributes: (NSDictionary **)dict
baseURL: (NSURL *)base
documentAttributes: (NSDictionary **)dict
{
if (data == nil)
{
RELEASE (self);
return nil;
}
// FIXME: Not implemented
return self;
}