([NSString -substringFromRange:]): Fix bug in references to string

length.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1677 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Andrew McCallum 1996-09-02 15:53:47 +00:00
parent 370a3ac19f
commit fd3b4b308e

View file

@ -484,10 +484,11 @@ handle_printf_atsign (FILE *stream,
- (NSString*) substringFromRange: (NSRange)aRange
{
unichar buffer[aRange.length];
int count = [self length];
if (aRange.location > _count)
if (aRange.location > count)
[NSException raise: NSRangeException format: @"Invalid location."];
if (aRange.length > (_count - aRange.location))
if (aRange.length > (count - aRange.location))
[NSException raise: NSRangeException format: @"Invalid location+length."];
[self getCharacters: buffer range: aRange];
return [[self class] stringWithCharacters: buffer length: aRange.length];