Fix bug getting cstring from literal containing illegal characters.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@25227 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2007-06-08 06:00:11 +00:00
parent 7fce994a67
commit d1f2ea541a
3 changed files with 11 additions and 0 deletions

View file

@ -1,3 +1,8 @@
2007-06-08 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSString.m Fix bug getting cString from literal string
with illegal (non-ascii) characters.
2007-06-06 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSKeyValueCoding.m: Use UTF8 rather than ASCII

View file

@ -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)
{

View file

@ -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];