diff --git a/ChangeLog b/ChangeLog index b204b08a9..7c30962c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2012-02-01 Fred Kiefer + + * Source/NSBitmapImageRep.m (-initWithFocusedViewRect:): Return + nil if the image data is empty. This could lead to an exception + alter on. + * Source/NSImage.m (-TIFFRepresentationUsingCompression:factor:, + -TIFFRepresentation): Deal with -initWithFocusedViewRect: returning nil. + 2012-02-01 Fred Kiefer * Source/NSMenu.m (-setMain:): Rearrange code to avoid duplicate diff --git a/Source/NSBitmapImageRep.m b/Source/NSBitmapImageRep.m index 5780c7072..54401dbb4 100644 --- a/Source/NSBitmapImageRep.m +++ b/Source/NSBitmapImageRep.m @@ -345,7 +345,7 @@ return nil; } _imageData = RETAIN([dict objectForKey: @"Data"]); - if (_imageData == nil) + if (_imageData == nil || [_imageData length] == 0) { NSLog(@"NSBitmapImageRep initWithFocusedViewRect: failed"); RELEASE(self); diff --git a/Source/NSImage.m b/Source/NSImage.m index bda01311c..a9e77dbf3 100644 --- a/Source/NSImage.m +++ b/Source/NSImage.m @@ -1491,9 +1491,12 @@ static NSSize GSResolutionOfImageRep(NSImageRep *rep) rep = [[NSBitmapImageRep alloc] initWithFocusedViewRect: NSMakeRect(0.0, 0.0, size.width, size.height)]; [self unlockFocus]; - [self addRepresentation: rep]; - data = [rep TIFFRepresentation]; - RELEASE(rep); + if (nil != rep) + { + [self addRepresentation: rep]; + data = [rep TIFFRepresentation]; + RELEASE(rep); + } } return data; @@ -1519,9 +1522,12 @@ static NSSize GSResolutionOfImageRep(NSImageRep *rep) rep = [[NSBitmapImageRep alloc] initWithFocusedViewRect: NSMakeRect(0.0, 0.0, size.width, size.height)]; [self unlockFocus]; - [self addRepresentation: rep]; - data = [rep TIFFRepresentationUsingCompression: comp factor: aFloat]; - RELEASE(rep); + if (nil != rep) + { + [self addRepresentation: rep]; + data = [rep TIFFRepresentationUsingCompression: comp factor: aFloat]; + RELEASE(rep); + } } return data;