Tcl Source Code

Check-in [e45cee0c53]
Login

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

Overview
Comment:Fix for [5ee01098824881b5], lseq list conversion results in attempt to access freed memory.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | main
Files: files | file ages | folders
SHA3-256: e45cee0c53fb6f4ec2315677e1d8e7f7c5e7f300707f20bf3e9dc9ece5a417b9
User & Date: pooryorick 2023-05-17 12:09:27
References
2023-06-27
22:00 Ticket [26960060d7] lseq-3.14 triggers use-after-free status still Open with 5 other changes artifact: 491b671f56 user: chrstphrchvz
2023-05-17
12:12 Pending ticket [5ee0109882]: lseq list conversion results in attempt to access freed memory plus 3 other changes artifact: 6354af3f3a user: pooryorick
Context
2023-06-28
07:20
Fix [26960060d7]: lseq-3.14 triggers use-after-free check-in: 68c0bd3f02 user: jan.nijtmans tags: core-8-branch
2023-05-17
12:26
New functions: TclUndoRefCount() and TclDictGetSize(). check-in: 60d6e1d587 user: pooryorick tags: trunk, main
12:09
Fix for [5ee01098824881b5], lseq list conversion results in attempt to access freed memory. check-in: e45cee0c53 user: pooryorick tags: trunk, main
07:33
Merge 8.7 check-in: 57e46213e1 user: jan.nijtmans tags: trunk, main
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tclListObj.c.

3321
3322
3323
3324
3325
3326
3327

3328
3329
3330
3331
3332
3333
3334
	listRep.storePtr->numUsed = size;
	elemPtrs = listRep.storePtr->slots;
	for (j = 0; j < size; j++) {
	    elemPtrs[j] = TclArithSeriesObjIndex(interp, objPtr, j);
	    if (elemPtrs[j] == NULL) {
		return TCL_ERROR;
	    }

	}

    } else {
	Tcl_Size estCount, length;
	const char *limit, *nextElem = Tcl_GetStringFromObj(objPtr, &length);

	/*







>







3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
	listRep.storePtr->numUsed = size;
	elemPtrs = listRep.storePtr->slots;
	for (j = 0; j < size; j++) {
	    elemPtrs[j] = TclArithSeriesObjIndex(interp, objPtr, j);
	    if (elemPtrs[j] == NULL) {
		return TCL_ERROR;
	    }
	    Tcl_IncrRefCount(elemPtrs[j]);
	}

    } else {
	Tcl_Size estCount, length;
	const char *limit, *nextElem = Tcl_GetStringFromObj(objPtr, &length);

	/*

Changes to tests/lseq.test.

581
582
583
584
585
586
587






588
589
590
591
592
593
594
test lseq-4.16 {bug lseq - inconsistent rounding} {
    # using a non-integer increment, [lseq] rounding seems to be not consistent:
    set res {}
    lappend res [lseq 4.07 6 0.1]
    lappend res [lseq 4.03 4.208 0.013]
} {{4.07 4.17 4.27 4.37 4.47 4.57 4.67 4.77 4.87 4.97 5.07 5.17 5.27 5.37 5.47 5.57 5.67 5.77 5.87 5.97} {4.03 4.043 4.056 4.069 4.082 4.095 4.108 4.121 4.134 4.147 4.16 4.173 4.186 4.199}}







# cleanup
::tcltest::cleanupTests

return

# Local Variables:
# mode: tcl







>
>
>
>
>
>







581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
test lseq-4.16 {bug lseq - inconsistent rounding} {
    # using a non-integer increment, [lseq] rounding seems to be not consistent:
    set res {}
    lappend res [lseq 4.07 6 0.1]
    lappend res [lseq 4.03 4.208 0.013]
} {{4.07 4.17 4.27 4.37 4.47 4.57 4.67 4.77 4.87 4.97 5.07 5.17 5.27 5.37 5.47 5.57 5.67 5.77 5.87 5.97} {4.03 4.043 4.056 4.069 4.082 4.095 4.108 4.121 4.134 4.147 4.16 4.173 4.186 4.199}}

test lseq-convertToList {does not result in a memory error} {
	trace add variable var1 write [list ::apply [list args {
		error {this is an error}
	} [namespace current]]]
	list [catch {set var1 [lindex [lreplace [lseq 1 2] 1 1 hello] 0]} cres] $cres
} {1 {can't set "var1": this is an error}}
# cleanup
::tcltest::cleanupTests

return

# Local Variables:
# mode: tcl