Tcl Source Code

Check-in [cf3aa0440e]
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:[824752f10e] More robust, portable check for integer overflow.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: cf3aa0440e048aa365999a365195f3b61e45b7e4
User & Date: dgp 2016-11-04 14:48:36
Context
2016-11-04
14:49
merge mark check-in: 9cd4c5200b user: dgp tags: trunk
14:48
[824752f10e] More robust, portable check for integer overflow. check-in: cf3aa0440e user: dgp tags: trunk
14:42
close fork check-in: e5a5037389 user: dgp tags: trunk
14:40
[824752f10e] More robust, portable check for integer overflow. check-in: b2a4266498 user: dgp tags: core-8-6-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tclListObj.c.

893
894
895
896
897
898
899

900
901
902
903
904
905
906
907
908
909
910
911
	first = 0;
    }
    if (first >= numElems) {
	first = numElems;	/* So we'll insert after last element. */
    }
    if (count < 0) {
	count = 0;

    } else if (numElems < first+count || first+count < 0) {
	/*
	 * The 'first+count < 0' condition here guards agains integer
	 * overflow in determining 'first+count'.
	 */

	count = numElems - first;
    }

    if (objc > LIST_MAX - (numElems - count)) {
	if (interp != NULL) {
	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(






>
|
<
<
<
<







893
894
895
896
897
898
899
900
901




902
903
904
905
906
907
908
	first = 0;
    }
    if (first >= numElems) {
	first = numElems;	/* So we'll insert after last element. */
    }
    if (count < 0) {
	count = 0;
    } else if (first > INT_MAX - count /* Handle integer overflow */
	    || numElems < first+count) {





	count = numElems - first;
    }

    if (objc > LIST_MAX - (numElems - count)) {
	if (interp != NULL) {
	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(