Tcl Source Code

Check-in [a87c1542ff]
Login

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

Overview
Comment:[Bug 3598580]: Tcl_ListObjReplace may release deleted elements too early

Tests!? Where are the tests!?!

They are in test listobj-11.1

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core-8-4-branch
Files: files | file ages | folders
SHA1: a87c1542ffb0f342bb66a94e5514e4477055e20e
User & Date: jan.nijtmans 2012-12-27 14:41:15
Original Comment: [Bug 3598580]: Tcl_ListObjReplace may release deleted elements too earl
Context
2013-01-02
14:12
test Tcl_GetErrorLine() forwards/backwards compatibility in pkgb.so as well check-in: dc8d23490a user: jan.nijtmans tags: core-8-4-branch
2012-12-27
14:57
[Bug 3598580]: Tcl_ListObjReplace may release deleted elements too early check-in: 6d560f6812 user: jan.nijtmans tags: core-8-5-branch
14:41
[Bug 3598580]: Tcl_ListObjReplace may release deleted elements too early

Tests!? Where are the t... check-in: a87c1542ff user: jan.nijtmans tags: core-8-4-branch

2012-12-21
08:16
Turn pkgb.so into a Tcl9 interoperability test library: Whatever Tcl9 looks like, loading pkgb.so in... check-in: f3a3b2cd2a user: jan.nijtmans tags: core-8-4-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.






1
2
3
4
5
6
7





2012-12-21  Jan Nijtmans  <[email protected]>

	* unix/dltest/pkgb.c:  Turn pkgb.so into a Tcl9 interoperability test
    library: Whatever Tcl9 looks like, loading pkgb.so in Tcl 9 should
    either result in an error-message, either succeed, but never crash.
	* generic/tclStubLib.c: Eliminate unnessarcy static HasStubSupport() and
	isDigit() functions, just do the same inline.
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
2012-12-27  Jan Nijtmans  <[email protected]>

	* generic/tclListObj.c: [Bug 3598580]: Tcl_ListObjReplace may release
	deleted elements too early

2012-12-21  Jan Nijtmans  <[email protected]>

	* unix/dltest/pkgb.c:  Turn pkgb.so into a Tcl9 interoperability test
    library: Whatever Tcl9 looks like, loading pkgb.so in Tcl 9 should
    either result in an error-message, either succeed, but never crash.
	* generic/tclStubLib.c: Eliminate unnessarcy static HasStubSupport() and
	isDigit() functions, just do the same inline.

Changes to generic/tclListObj.c.

651
652
653
654
655
656
657




658
659
660
661
662
663
664
    if (first >= numElems) {
	first = numElems;	/* so we'll insert after last element */
    }
    if (count < 0) {
	count = 0;
    }
    




    numRequired = (numElems - count + objc);
    if (numRequired <= listRepPtr->maxElemCount) {
	/*
	 * Enough room in the current array. First "delete" count
	 * elements starting at first.
	 */








>
>
>
>







651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
    if (first >= numElems) {
	first = numElems;	/* so we'll insert after last element */
    }
    if (count < 0) {
	count = 0;
    }
    
    for (i = 0;  i < objc;  i++) {
	Tcl_IncrRefCount(objv[i]);
    }

    numRequired = (numElems - count + objc);
    if (numRequired <= listRepPtr->maxElemCount) {
	/*
	 * Enough room in the current array. First "delete" count
	 * elements starting at first.
	 */

685
686
687
688
689
690
691
692
693
694
695
696
697
698
699

	/*
	 * Insert the new elements into elemPtrs before "first".
	 */

	for (i = 0, j = first;  i < objc;  i++, j++) {
            elemPtrs[j] = objv[i];
            Tcl_IncrRefCount(objv[i]);
        }

	/*
	 * Update the count of elements.
	 */

	listRepPtr->elemCount = numRequired;







<







689
690
691
692
693
694
695

696
697
698
699
700
701
702

	/*
	 * Insert the new elements into elemPtrs before "first".
	 */

	for (i = 0, j = first;  i < objc;  i++, j++) {
            elemPtrs[j] = objv[i];

        }

	/*
	 * Update the count of elements.
	 */

	listRepPtr->elemCount = numRequired;
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
	/*
	 * Insert the new elements before "first" and update the
	 * count of elements.
	 */

	for (i = 0, j = first;  i < objc;  i++, j++) {
	    newPtrs[j] = objv[i];
	    Tcl_IncrRefCount(objv[i]);
	}

	listRepPtr->elemCount = numRequired;
	listRepPtr->maxElemCount = newMax;
	listRepPtr->elements = newPtrs;
	ckfree((char *) elemPtrs);
    }







<







744
745
746
747
748
749
750

751
752
753
754
755
756
757
	/*
	 * Insert the new elements before "first" and update the
	 * count of elements.
	 */

	for (i = 0, j = first;  i < objc;  i++, j++) {
	    newPtrs[j] = objv[i];

	}

	listRepPtr->elemCount = numRequired;
	listRepPtr->maxElemCount = newMax;
	listRepPtr->elements = newPtrs;
	ckfree((char *) elemPtrs);
    }