Tcl Source Code

Check-in [81046b694f]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:A confusion about signed vs unsigned comparision caused Tcl_UtfToUniChar() to return the wrong answer (contents of random memory) for each single byte UTF-8 in the input. This commit fixes that bug. More commentary on https://core.tcl-lang.org/tcl/tktview/bd94500678
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core-8-branch
Files: files | file ages | folders
SHA3-256: 81046b694ffbdbcab1913da68dd88b592a04c0e31a899db99aba8f6cd0f00dc2
User & Date: dgp 2019-03-01 20:24:31
Context
2019-03-01
21:01
Update Unicode tables to version 12.0 check-in: 1ac480041b user: jan.nijtmans tags: core-8-branch
20:25
merge 8.7 check-in: bc57eb7213 user: dgp tags: trunk
20:24
A confusion about signed vs unsigned comparision caused Tcl_UtfToUniChar() to return the wrong answe... check-in: 81046b694f user: dgp tags: core-8-branch
2019-02-27
21:29
Fix [bd94500678e837d7]: SEGFAULT by conversion of unicode (out of BMP) to byte-array check-in: efe8f3e6b0 user: jan.nijtmans tags: core-8-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tclUtf.c.

327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
		&& (((((byte - 0x10) << 2) & 0xFC) | 0xD800) == (*chPtr & 0xFCFC))
		&& ((src[1] & 0xF0) == (((*chPtr << 4) & 0x30) | 0x80))
		&& ((src[2] & 0xC0) == 0x80)) {
	    *chPtr = ((src[1] & 0x0F) << 6) + (src[2] & 0x3F) + 0xDC00;
	    return 3;
	}
#endif
	if (byte-0x80 < 0x20) {
	    *chPtr = cp1252[byte-0x80];
	} else {
	    *chPtr = byte;
	}
	return 1;
    } else if (byte < 0xE0) {
	if ((src[1] & 0xC0) == 0x80) {






|







327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
		&& (((((byte - 0x10) << 2) & 0xFC) | 0xD800) == (*chPtr & 0xFCFC))
		&& ((src[1] & 0xF0) == (((*chPtr << 4) & 0x30) | 0x80))
		&& ((src[2] & 0xC0) == 0x80)) {
	    *chPtr = ((src[1] & 0x0F) << 6) + (src[2] & 0x3F) + 0xDC00;
	    return 3;
	}
#endif
	if ((unsigned)(byte-0x80) < (unsigned)0x20) {
	    *chPtr = cp1252[byte-0x80];
	} else {
	    *chPtr = byte;
	}
	return 1;
    } else if (byte < 0xE0) {
	if ((src[1] & 0xC0) == 0x80) {