mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Fix replaceBytesInRnage:withBytes: range check error
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/branches/freeze-1_0_0@9492 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c1b35d9487
commit
feae94c21d
1 changed files with 15 additions and 9 deletions
|
@ -1536,16 +1536,19 @@ failure:
|
|||
unsigned size = [self length];
|
||||
unsigned need = NSMaxRange(aRange);
|
||||
|
||||
if (aRange.location >= size)
|
||||
if (aRange.location > size)
|
||||
{
|
||||
[NSException raise: NSRangeException
|
||||
format: @"location bad in replaceByteInRange:withBytes:"];
|
||||
}
|
||||
if (need > size)
|
||||
if (aRange.length > 0)
|
||||
{
|
||||
[self setLength: need];
|
||||
if (need > size)
|
||||
{
|
||||
[self setLength: need];
|
||||
}
|
||||
memcpy([self mutableBytes] + aRange.location, bytes, aRange.length);
|
||||
}
|
||||
memcpy([self mutableBytes] + aRange.location, bytes, aRange.length);
|
||||
}
|
||||
|
||||
- (void) resetBytesInRange: (NSRange)aRange
|
||||
|
@ -2702,17 +2705,20 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
{
|
||||
unsigned need = NSMaxRange(aRange);
|
||||
|
||||
if (aRange.location >= length)
|
||||
if (aRange.location > length)
|
||||
{
|
||||
[NSException raise: NSRangeException
|
||||
format: @"location bad in replaceByteInRange:withBytes:"];
|
||||
}
|
||||
if (need > length)
|
||||
if (aRange.length > 0)
|
||||
{
|
||||
[self setCapacity: need];
|
||||
length = need;
|
||||
if (need > length)
|
||||
{
|
||||
[self setCapacity: need];
|
||||
length = need;
|
||||
}
|
||||
memcpy(bytes + aRange.location, moreBytes, aRange.length);
|
||||
}
|
||||
memcpy(bytes + aRange.location, moreBytes, aRange.length);
|
||||
}
|
||||
|
||||
- (void) serializeDataAt: (const void*)data
|
||||
|
|
Loading…
Reference in a new issue