String.Right() does not crash anymore on invalid UTF-8 strings.

[INTERPRETER]
* BUG: String.Right() does not crash anymore on invalid UTF-8 strings.
This commit is contained in:
gambas 2019-03-08 12:28:41 +01:00
parent 463bc16b47
commit c7d6ddd31f

View file

@ -535,6 +535,8 @@ static void String_Right(ushort code)
val = utf8_get_length(str, len) - val;
ulen = utf8_get_pos(ref, str, len, val);
if (ulen > len)
ulen = len;
PARAM->_string.start += ulen;
PARAM->_string.len -= ulen;
@ -834,7 +836,7 @@ END_METHOD
#define IS_VALID(_char) \
((_char) < 0x110000 && \
(((_char) & 0xFFFFF800) != 0xD800) && \
(((_char) & 0xFFFFF800) != 0xD800) && \
((_char) < 0xFDD0 || (_char) > 0xFDEF) && \
((_char) & 0xFFFE) != 0xFFFE)