Add a couple of tests for errors.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@24186 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2006-12-05 14:20:55 +00:00
parent aa920a0395
commit c51ffc03af
3 changed files with 32 additions and 15 deletions

View file

@ -2564,7 +2564,15 @@ handle_printf_atsign (FILE *stream,
unsigned length = [d length];
BOOL result = (length <= maxLength) ? YES : NO;
if (length > maxLength) length = maxLength;
if (d == nil)
{
[NSException raise: NSCharacterConversionException
format: @"Can't convert to C string."];
}
if (length > maxLength)
{
length = maxLength;
}
memcpy(buffer, [d bytes], length);
buffer[length] = '\0';
return result;