mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
Minor range check fixes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@6295 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
5727555328
commit
e1b32b96e9
3 changed files with 66 additions and 37 deletions
|
@ -849,39 +849,51 @@ static inline void
|
|||
stringIncrementCountAndMakeHoleAt(NSGMutableCStringStruct *self,
|
||||
int index, int size)
|
||||
{
|
||||
if (size > 0)
|
||||
{
|
||||
if (self->_count > 0)
|
||||
{
|
||||
#ifndef STABLE_MEMCPY
|
||||
{
|
||||
unsigned i = self->_count;
|
||||
unsigned i = self->_count;
|
||||
|
||||
while (i-- > index)
|
||||
self->_contents_chars[i+size] = self->_contents_chars[i];
|
||||
}
|
||||
while (i-- > index)
|
||||
{
|
||||
self->_contents_chars[i+size] = self->_contents_chars[i];
|
||||
}
|
||||
#else
|
||||
memcpy(self->_contents_chars + index,
|
||||
self->_contents_chars + index + size,
|
||||
self->_count - index);
|
||||
memcpy(self->_contents_chars + index,
|
||||
self->_contents_chars + index + size,
|
||||
self->_count - index);
|
||||
#endif /* STABLE_MEMCPY */
|
||||
(self->_count) += size;
|
||||
(self->_hash) = 0;
|
||||
}
|
||||
self->_count += size;
|
||||
self->_hash = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
stringDecrementCountAndFillHoleAt(NSGMutableCStringStruct *self,
|
||||
int index, int size)
|
||||
{
|
||||
(self->_count) -= size;
|
||||
if (size > 0)
|
||||
{
|
||||
self->_count -= size;
|
||||
#ifndef STABLE_MEMCPY
|
||||
{
|
||||
int i;
|
||||
for (i = index; i <= self->_count; i++)
|
||||
self->_contents_chars[i] = self->_contents_chars[i+size];
|
||||
}
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = index; i <= self->_count; i++)
|
||||
{
|
||||
self->_contents_chars[i] = self->_contents_chars[i+size];
|
||||
}
|
||||
}
|
||||
#else
|
||||
memcpy(self->_contents_chars + index + size,
|
||||
self->_contents_chars + index,
|
||||
self->_count - index);
|
||||
memcpy(self->_contents_chars + index + size,
|
||||
self->_contents_chars + index,
|
||||
self->_count - index);
|
||||
#endif /* STABLE_MEMCPY */
|
||||
(self->_hash) = 0;
|
||||
self->_hash = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* This is the designated initializer for this class */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue