Tcl Source Code

Check-in [8b3e6a3ee5]
Login

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

Overview
Comment:TclTrim must write to *trimRight even when making a quick exit.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | core-8-5-branch
Files: files | file ages | folders
SHA3-256: 8b3e6a3ee5f845da3ac5669a456f66ec96259718dc202e76cdb8f4150d4500ec
User & Date: dgp 2018-03-14 00:45:14.596
Context
2018-03-14
17:17
TclTrim: special case for TrimRight on single char result of TrimLeft (this char is already verified... check-in: 96a6332cff user: sebres tags: core-8-5-branch
00:53
merge 8.5 check-in: 4fd30be85b user: dgp tags: core-8-6-branch
00:45
TclTrim must write to *trimRight even when making a quick exit. check-in: 8b3e6a3ee5 user: dgp tags: core-8-5-branch
00:03
Make TclTrim* routines robust against some malformation in inputs. Better than access violations and... check-in: e2a4fef6e1 user: dgp tags: core-8-5-branch
Changes
Unified Diff Ignore Whitespace Patch
Changes to generic/tclUtil.c.
1736
1737
1738
1739
1740
1741
1742

1743
1744
1745
1746
1747
1748
1749
    int *trimRight)		/* Offset from the end of the string. */
{
    int trimLeft;
    Tcl_DString bytesBuf, trimBuf;

    /* Empty strings -> nothing to do */
    if ((numBytes == 0) || (numTrim == 0)) {

	return 0;
    }

    Tcl_DStringInit(&bytesBuf);
    Tcl_DStringInit(&trimBuf);
    bytes = UtfWellFormedEnd(&bytesBuf, bytes, numBytes);
    trim = UtfWellFormedEnd(&trimBuf, trim, numTrim);







>







1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
    int *trimRight)		/* Offset from the end of the string. */
{
    int trimLeft;
    Tcl_DString bytesBuf, trimBuf;

    /* Empty strings -> nothing to do */
    if ((numBytes == 0) || (numTrim == 0)) {
	*trimRight = 0;
	return 0;
    }

    Tcl_DStringInit(&bytesBuf);
    Tcl_DStringInit(&trimBuf);
    bytes = UtfWellFormedEnd(&bytesBuf, bytes, numBytes);
    trim = UtfWellFormedEnd(&trimBuf, trim, numTrim);