Tcl Source Code

Check-in [fa3278ec35]
Login

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

Overview
Comment:Correct NULL dereference, and optimize short-circuit logical operation
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | amg-string-insert
Files: files | file ages | folders
SHA1: fa3278ec35dc6897d503352e8f0f9a7540257c32
User & Date: andy 2017-08-20 03:20:45
Context
2017-08-20
03:21
Reimplement NON-BYTECODED [string replace] in terms of new TclStringReplace() function check-in: c0036938dd user: andy tags: amg-string-insert
03:20
Correct NULL dereference, and optimize short-circuit logical operation check-in: fa3278ec35 user: andy tags: amg-string-insert
02:44
Work toward dgp's suggestion that the underlying engine handle both [string insert] and [string repl... check-in: 0cfeecb740 user: andy tags: amg-string-insert
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tclStringObj.c.

3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
     */

    if (!insObj) {
	insLen = 0;
    } else if (pureBin && (pureBin &= TclIsPureByteArray(insObj))) {
	insBin = Tcl_GetByteArrayFromObj(insObj, &insLen);
    } else {
	pureUni &= !insObj->bytes;
	insUni = Tcl_GetUnicodeFromObj(insObj, &insLen);
    }

    /*
     * Clip start index and removal count to lie within string length limits.
     */








|







3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
     */

    if (!insObj) {
	insLen = 0;
    } else if (pureBin && (pureBin &= TclIsPureByteArray(insObj))) {
	insBin = Tcl_GetByteArrayFromObj(insObj, &insLen);
    } else {
	pureUni = pureUni && !insObj->bytes;
	insUni = Tcl_GetUnicodeFromObj(insObj, &insLen);
    }

    /*
     * Clip start index and removal count to lie within string length limits.
     */

3585
3586
3587
3588
3589
3590
3591

3592

3593
3594
3595
3596
3597
3598
3599
    } else {
	/*
	 * Non-byte array, non-Unicode, non-prepend, non-append, non-empty,
	 * non-unshared case.  Build a new string by concatenating the parts.
	 */

	outObj = Tcl_NewUnicodeObj(strUni, idx);

	Tcl_AppendObjToObj(outObj, insObj);

	if (strLen != idx + del) {
	    Tcl_AppendUnicodeToObj(outObj, strUni + idx + del,
		    strLen - idx - del);
	}
    }

    return outObj;







>
|
>







3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
    } else {
	/*
	 * Non-byte array, non-Unicode, non-prepend, non-append, non-empty,
	 * non-unshared case.  Build a new string by concatenating the parts.
	 */

	outObj = Tcl_NewUnicodeObj(strUni, idx);
	if (insLen) {
	    Tcl_AppendObjToObj(outObj, insObj);
	}
	if (strLen != idx + del) {
	    Tcl_AppendUnicodeToObj(outObj, strUni + idx + del,
		    strLen - idx - del);
	}
    }

    return outObj;