summaryrefslogtreecommitdiffstats
path: root/generic/tclListObj.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2016-11-04 14:40:54 (GMT)
committerdgp <dgp@users.sourceforge.net>2016-11-04 14:40:54 (GMT)
commita188ceee2158cb9446f926f4d950a3a98377b988 (patch)
tree3f4fd384aa651b0b58da2de05866a89565aca1d1 /generic/tclListObj.c
parenteb87ed60f674e52f1e29227bce5422a860b6bd28 (diff)
parentbc94a394c9804482091ed3a2a5d83652397138c8 (diff)
downloadtcl-a188ceee2158cb9446f926f4d950a3a98377b988.zip
tcl-a188ceee2158cb9446f926f4d950a3a98377b988.tar.gz
tcl-a188ceee2158cb9446f926f4d950a3a98377b988.tar.bz2
[824752f10e] More robust, portable check for integer overflow.
Diffstat (limited to 'generic/tclListObj.c')
-rw-r--r--generic/tclListObj.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/generic/tclListObj.c b/generic/tclListObj.c
index 2929423..344d0fd 100644
--- a/generic/tclListObj.c
+++ b/generic/tclListObj.c
@@ -897,11 +897,8 @@ Tcl_ListObjReplace(
}
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'.
- */
+ } else if (first > INT_MAX - count /* Handle integer overflow */
+ || numElems < first+count) {
count = numElems - first;
}