diff --git a/ChangeLog b/ChangeLog index 8cc274aa2..6a02cd076 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-06-08 Richard Frith-Macdonald + + * Source/GSString.m Fix bug getting cString from literal string + with illegal (non-ascii) characters. + 2007-06-06 Richard Frith-Macdonald * Source/NSKeyValueCoding.m: Use UTF8 rather than ASCII diff --git a/Source/GSString.m b/Source/GSString.m index 1afb07543..b87aabde7 100644 --- a/Source/GSString.m +++ b/Source/GSString.m @@ -1864,6 +1864,7 @@ getCStringE_c(GSStr self, char *buffer, unsigned int maxLength, * from internal format to unicode and then to the specified * C string encoding. */ + bytes = maxLength - sizeof(char); if (GSToUnicode(&u, &l, self->_contents.c, self->_count, internalEncoding, NSDefaultMallocZone(), 0) == NO) { diff --git a/Source/NSKeyValueCoding.m b/Source/NSKeyValueCoding.m index e3a725a72..a2f426896 100644 --- a/Source/NSKeyValueCoding.m +++ b/Source/NSKeyValueCoding.m @@ -554,6 +554,11 @@ static id ValueForKey(NSObject *self, const char *key, unsigned size) char key[size+1]; GSOnceMLog(@"This method is deprecated, use -setValue:forKey:"); + if (anObject == nil) + { + [NSException raise: NSInvalidArgumentException + format: @"Attempt to set nil value for key '%@'", aKey]; + } [aKey getCString: key maxLength: size+1 encoding: NSUTF8StringEncoding];