diff options
author | dgp <dgp@users.sourceforge.net> | 2017-06-05 17:15:11 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2017-06-05 17:15:11 (GMT) |
commit | 0b178367ba3b9a10d44f89025c89292a4ea49b20 (patch) | |
tree | 853c1526b11c08616068ce931e63175c687bfd8f /generic | |
parent | 1d537a6b450c04d52d93f2c04bf3135b60711e61 (diff) | |
parent | 67fd012128e6e76e3d745ca090075acbcfa9f258 (diff) | |
download | tcl-0b178367ba3b9a10d44f89025c89292a4ea49b20.zip tcl-0b178367ba3b9a10d44f89025c89292a4ea49b20.tar.gz tcl-0b178367ba3b9a10d44f89025c89292a4ea49b20.tar.bz2 |
[67aa9a2070] Tcl_UtfToUniChar returns single byte for invalid UTF-8 input as documented.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclUtf.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/generic/tclUtf.c b/generic/tclUtf.c index b33bf6a..eec4068 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -292,7 +292,9 @@ Tcl_UtfToUniChar( */ *chPtr = (Tcl_UniChar) (((byte & 0x1F) << 6) | (src[1] & 0x3F)); - return 2; + if ((*chPtr == 0) || (*chPtr > 0x7f)) { + return 2; + } } /* @@ -307,7 +309,9 @@ Tcl_UtfToUniChar( *chPtr = (Tcl_UniChar) (((byte & 0x0F) << 12) | ((src[1] & 0x3F) << 6) | (src[2] & 0x3F)); - return 3; + if (*chPtr > 0x7ff) { + return 3; + } } /* @@ -324,7 +328,9 @@ Tcl_UtfToUniChar( *chPtr = (Tcl_UniChar) (((byte & 0x0E) << 18) | ((src[1] & 0x3F) << 12) | ((src[2] & 0x3F) << 6) | (src[3] & 0x3F)); - return 4; + if ((*chPtr <= 0x10ffff) && (*chPtr > 0xffff)) { + return 4; + } } /* |