mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
Fix a whole bunch of potential crashers in NSAttributedString.m and
NSDocument.m where the error return parameter was written to without a null pointer check. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29580 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
94946a1f50
commit
ba58449d3c
3 changed files with 60 additions and 33 deletions
|
@ -1,3 +1,10 @@
|
|||
2010-02-12 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* Source/NSAttributedString.m:
|
||||
* Source/NSDocument.m: Fix a whole bunch of potential crashers
|
||||
where the error return parameter was written to without a null
|
||||
pointer check.
|
||||
|
||||
2010-02-11 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* NSTableHeaderView.m:
|
||||
|
|
|
@ -756,8 +756,9 @@ create_error(int code, NSString* desc)
|
|||
|
||||
if (data == nil)
|
||||
{
|
||||
*error = create_error(0, NSLocalizedString(@"No data specified for data loading.",
|
||||
@"Error description"));
|
||||
if (error)
|
||||
*error = create_error(0, NSLocalizedString(@"No data specified for data loading.",
|
||||
@"Error description"));
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
|
@ -765,8 +766,9 @@ create_error(int code, NSString* desc)
|
|||
if (type == nil)
|
||||
{
|
||||
// FIXME: try to determine type
|
||||
*error = create_error(0, NSLocalizedString(@"No type specified for data.",
|
||||
@"Error description"));
|
||||
if (error)
|
||||
*error = create_error(0, NSLocalizedString(@"No type specified for data.",
|
||||
@"Error description"));
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
|
@ -804,8 +806,9 @@ create_error(int code, NSString* desc)
|
|||
return self;
|
||||
}
|
||||
|
||||
*error = create_error(0, NSLocalizedString(@"Could not load data.",
|
||||
@"Error description"));
|
||||
if (error)
|
||||
*error = create_error(0, NSLocalizedString(@"Could not load data.",
|
||||
@"Error description"));
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
|
@ -842,14 +845,13 @@ create_error(int code, NSString* desc)
|
|||
- (id) initWithURL: (NSURL *)url
|
||||
documentAttributes: (NSDictionary **)dict
|
||||
{
|
||||
NSError *error = nil;
|
||||
NSDictionary *options = [NSDictionary dictionaryWithObject: [url baseURL]
|
||||
forKey: NSBaseURLDocumentOption];
|
||||
|
||||
return [self initWithURL: url
|
||||
options: options
|
||||
documentAttributes: dict
|
||||
error: &error];
|
||||
error: NULL];
|
||||
}
|
||||
|
||||
- (id) initWithURL: (NSURL *)url
|
||||
|
@ -861,8 +863,9 @@ documentAttributes: (NSDictionary **)dict
|
|||
|
||||
if (data == nil)
|
||||
{
|
||||
*error = create_error(0, NSLocalizedString(@"Could not load data from URL.",
|
||||
@"Error description"));
|
||||
if (error)
|
||||
*error = create_error(0, NSLocalizedString(@"Could not load data from URL.",
|
||||
@"Error description"));
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
|
@ -962,8 +965,9 @@ documentAttributes: (NSDictionary **)dict
|
|||
|
||||
if (type == nil)
|
||||
{
|
||||
*error = create_error(0, NSLocalizedString(@"No type specified for data.",
|
||||
@"Error description"));
|
||||
if (error)
|
||||
*error = create_error(0, NSLocalizedString(@"No type specified for data.",
|
||||
@"Error description"));
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
@ -988,8 +992,9 @@ documentAttributes: (NSDictionary **)dict
|
|||
return [[self string] dataUsingEncoding: encoding];
|
||||
}
|
||||
|
||||
*error = create_error(0, NSLocalizedString(@"Could not create data for type.",
|
||||
@"Error description"));
|
||||
if (error)
|
||||
*error = create_error(0, NSLocalizedString(@"Could not create data for type.",
|
||||
@"Error description"));
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
@ -1010,9 +1015,9 @@ documentAttributes: (NSDictionary **)dict
|
|||
return AUTORELEASE(wrapper);
|
||||
}
|
||||
|
||||
if (*error == nil)
|
||||
*error = create_error(0, NSLocalizedString(@"Could not create data for type.",
|
||||
@"Error description"));
|
||||
if (error)
|
||||
*error = create_error(0, NSLocalizedString(@"Could not create data for type.",
|
||||
@"Error description"));
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
|
|
@ -581,7 +581,8 @@ withContentsOfURL: (NSURL *)url
|
|||
{
|
||||
if (OVERRIDDEN(dataRepresentationOfType:))
|
||||
{
|
||||
*error = nil;
|
||||
if (error)
|
||||
*error = nil;
|
||||
return [self dataRepresentationOfType: type];
|
||||
}
|
||||
|
||||
|
@ -614,7 +615,8 @@ withContentsOfURL: (NSURL *)url
|
|||
|
||||
if (OVERRIDDEN(fileWrapperRepresentationOfType:))
|
||||
{
|
||||
*error = nil;
|
||||
if (error)
|
||||
*error = nil;
|
||||
return [self fileWrapperRepresentationOfType: type];
|
||||
}
|
||||
|
||||
|
@ -693,7 +695,8 @@ withContentsOfURL: (NSURL *)url
|
|||
{
|
||||
if (OVERRIDDEN(loadDataRepresentation:ofType:))
|
||||
{
|
||||
*error = nil;
|
||||
if (error)
|
||||
*error = nil;
|
||||
return [self loadDataRepresentation: data
|
||||
ofType: type];
|
||||
}
|
||||
|
@ -709,7 +712,8 @@ withContentsOfURL: (NSURL *)url
|
|||
{
|
||||
if (OVERRIDDEN(loadFileWrapperRepresentation:ofType:))
|
||||
{
|
||||
*error = nil;
|
||||
if (error)
|
||||
*error = nil;
|
||||
return [self loadFileWrapperRepresentation: wrapper ofType: type];
|
||||
}
|
||||
|
||||
|
@ -721,7 +725,8 @@ withContentsOfURL: (NSURL *)url
|
|||
}
|
||||
|
||||
// FIXME: Set error
|
||||
*error = nil;
|
||||
if (error)
|
||||
*error = nil;
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
@ -735,7 +740,8 @@ withContentsOfURL: (NSURL *)url
|
|||
|
||||
if (OVERRIDDEN(readFromFile:ofType:))
|
||||
{
|
||||
*error = nil;
|
||||
if (error)
|
||||
*error = nil;
|
||||
return [self readFromFile: fileName ofType: type];
|
||||
}
|
||||
else
|
||||
|
@ -876,7 +882,8 @@ withContentsOfURL: (NSURL *)url
|
|||
isAutosave = YES;
|
||||
}
|
||||
|
||||
*error = nil;
|
||||
if (error)
|
||||
*error = nil;
|
||||
if (![self writeWithBackupToFile: [url path]
|
||||
ofType: type
|
||||
saveOperation: op])
|
||||
|
@ -895,7 +902,8 @@ withContentsOfURL: (NSURL *)url
|
|||
if (!isNativeType || (url == nil))
|
||||
{
|
||||
// FIXME: Set error
|
||||
*error = nil;
|
||||
if (error)
|
||||
*error = nil;
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
@ -914,7 +922,8 @@ withContentsOfURL: (NSURL *)url
|
|||
toFile: backupFilename])
|
||||
{
|
||||
// FIXME: Set error.
|
||||
*error = nil;
|
||||
if (error)
|
||||
*error = nil;
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
@ -973,7 +982,8 @@ withContentsOfURL: (NSURL *)url
|
|||
|
||||
if (OVERRIDDEN(writeToFile:ofType:))
|
||||
{
|
||||
*error = nil;
|
||||
if (error)
|
||||
*error = nil;
|
||||
return [self writeToFile: [url path] ofType: type];
|
||||
}
|
||||
|
||||
|
@ -982,11 +992,13 @@ withContentsOfURL: (NSURL *)url
|
|||
if (wrapper == nil)
|
||||
{
|
||||
// FIXME: Set error
|
||||
*error = nil;
|
||||
if (error)
|
||||
*error = nil;
|
||||
return NO;
|
||||
}
|
||||
|
||||
*error = nil;
|
||||
|
||||
if (error)
|
||||
*error = nil;
|
||||
return [wrapper writeToFile: [url path] atomically: YES updateFilenames: YES];
|
||||
}
|
||||
else
|
||||
|
@ -1013,7 +1025,8 @@ originalContentsURL: (NSURL *)orig
|
|||
op = NSSaveToOperation;
|
||||
}
|
||||
|
||||
*error = nil;
|
||||
if (error)
|
||||
*error = nil;
|
||||
return [self writeToFile: [url path]
|
||||
ofType: type
|
||||
originalFile: [orig path]
|
||||
|
@ -1393,7 +1406,8 @@ originalContentsURL: (NSURL *)orig
|
|||
- (NSPrintOperation *) printOperationWithSettings: (NSDictionary *)settings
|
||||
error: (NSError **)error
|
||||
{
|
||||
*error = nil;
|
||||
if (error)
|
||||
*error = nil;
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
@ -1463,7 +1477,8 @@ originalContentsURL: (NSURL *)orig
|
|||
error: (NSError **)error
|
||||
{
|
||||
// FIXME: Implement. Should set NSFileExtensionHidden
|
||||
*error = nil;
|
||||
if (error)
|
||||
*error = nil;
|
||||
|
||||
return [NSDictionary dictionary];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue