Improved range checks

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@4360 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 1999-06-04 16:05:45 +00:00
parent 839c470720
commit a620f606d9
2 changed files with 56 additions and 49 deletions

View file

@ -252,10 +252,11 @@
{
unsigned i, j = 0, e = aRange.location + aRange.length;
if (_count < e)
{
e = _count;
}
if (aRange.location >= _count)
[NSException raise: NSRangeException format:@"Invalid location."];
if (aRange.length > (_count - aRange.location))
[NSException raise: NSRangeException format:@"Invalid location+length."];
for (i = aRange.location; i < e; i++)
{
aBuffer[j++] = _contents_array[i];