mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-26 10:11:03 +00:00
(initWithCapacity:): Make sure that capacity is greater than zero.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@312 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
17dbbe2248
commit
3d1c766353
1 changed files with 3 additions and 2 deletions
|
@ -173,11 +173,12 @@ stringDecrementCountAndFillHoleAt(NSMutableCStringStruct *self,
|
|||
}
|
||||
|
||||
/* This is the designated initializer for this class */
|
||||
/* xxx Should capacity include the '\0' terminator? */
|
||||
- initWithCapacity: (unsigned)capacity
|
||||
{
|
||||
_count = 0;
|
||||
_capacity = capacity;
|
||||
OBJC_MALLOC(_contents_chars, char, _capacity+1);
|
||||
_capacity = MAX(capacity, 2);
|
||||
OBJC_MALLOC(_contents_chars, char, _capacity);
|
||||
_contents_chars[0] = '\0';
|
||||
return self;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue