raise exception on character conversion failure

This commit is contained in:
Richard Frith-Macdonald 2018-02-07 10:38:57 +00:00
parent 14c2d9402d
commit ad87ff5462
2 changed files with 6 additions and 2 deletions

View file

@ -3,6 +3,7 @@
* Source/GSAttributedString.m: remove a little dead code
* Tests/base/NSMutableAttributedString/test00.m: add sanity checks
* Tests/base/NSMutableAttributedString/test01.m: add sanity checks
* Source/GSString.m: raise exception on character conversion failure
2018-02-07 Yavor Doganov <yavor@gnu.org>

View file

@ -2120,8 +2120,11 @@ characterAtIndex_c(GSStr self, unsigned index)
unsigned int s = 1;
unichar *d = &u;
u = 0; // If conversion fails we use zero
GSToUnicode(&d, &s, &c, 1, internalEncoding, 0, 0);
if (GSToUnicode(&d, &s, &c, 1, internalEncoding, 0, 0) == NO)
{
[NSException raise: NSInternalInconsistencyException
format: @"unable to convert character to unicode"];
}
}
return u;
}