mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
Minor fix for strings initialised with data they don't own ... consistent
with MacOS-X implementation. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@18019 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
009855161e
commit
82c043f108
3 changed files with 62 additions and 9 deletions
|
@ -3848,11 +3848,14 @@ handle_printf_atsign (FILE *stream,
|
|||
|
||||
- (id) copyWithZone: (NSZone*)zone
|
||||
{
|
||||
if ([self isKindOfClass: [NSMutableString class]] ||
|
||||
NSShouldRetainWithZone(self, zone) == NO)
|
||||
return [[NSStringClass allocWithZone: zone] initWithString: self];
|
||||
else
|
||||
return RETAIN(self);
|
||||
/*
|
||||
* Default implementation should not simply retain ... the string may
|
||||
* have been initialised with freeWhenDone==NO and not own its
|
||||
* characters ... so the code which created it may destroy the memory
|
||||
* when it has finished with the original string ... leaving the
|
||||
* copy with pointers to invalid data. So, we always copy in full.
|
||||
*/
|
||||
return [[NSStringClass allocWithZone: zone] initWithString: self];
|
||||
}
|
||||
|
||||
- (id) mutableCopyWithZone: (NSZone*)zone
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue