* Source/NSNumberFormatter.m

(-attributedStringForObjectValue:withDefaultAttributes:):
Guard against initializing an NSAttributedString with a nil string.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33596 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Eric Wasylishen 2011-07-21 01:43:07 +00:00
parent e626936660
commit 5c802d5d57
2 changed files with 15 additions and 1 deletions

View file

@ -1,3 +1,9 @@
2011-07-20 Eric Wasylishen <ewasylishen@gmail.com>
* Source/NSNumberFormatter.m
(-attributedStringForObjectValue:withDefaultAttributes:):
Guard against initializing an NSAttributedString with a nil string.
2011-07-20 Eric Wasylishen <ewasylishen@gmail.com>
* Source/GSAttributedString.m: Throw an exception if the string object

View file

@ -437,6 +437,7 @@ static NSUInteger _defaultBehavior = NSNumberFormatterBehavior10_4;
- (NSAttributedString*) attributedStringForObjectValue: (id)anObject
withDefaultAttributes: (NSDictionary*)attr
{
NSString *stringForObjectValue;
NSDecimalNumber *zeroNumber = [NSDecimalNumber zero];
NSDecimalNumber *nanNumber = [NSDecimalNumber notANumber];
@ -468,8 +469,15 @@ static NSUInteger _defaultBehavior = NSNumberFormatterBehavior10_4;
attr = _attributesForNegativeValues;
}
stringForObjectValue = [self stringForObjectValue: anObject];
if (stringForObjectValue == nil)
{
stringForObjectValue = @"";
}
return AUTORELEASE([[NSAttributedString alloc] initWithString:
[self stringForObjectValue: anObject] attributes: attr]);
stringForObjectValue attributes: attr]);
}
- (NSAttributedString*) attributedStringForNil