summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2016-11-04 14:37:50 (GMT)
committerdgp <dgp@users.sourceforge.net>2016-11-04 14:37:50 (GMT)
commit09077eceec17bc1586d2aefe2c38b857425045e6 (patch)
treec71d587b9d044260ca682ddbf5658b275820ff3e /generic
parent6f7ca1db34f65411ee5779dcab9c0a0255adb713 (diff)
downloadtcl-09077eceec17bc1586d2aefe2c38b857425045e6.zip
tcl-09077eceec17bc1586d2aefe2c38b857425045e6.tar.gz
tcl-09077eceec17bc1586d2aefe2c38b857425045e6.tar.bz2
[824752f10e] More robust, portable check for integer overflow.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclListObj.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/generic/tclListObj.c b/generic/tclListObj.c
index 22f1960..e1dba8c 100644
--- a/generic/tclListObj.c
+++ b/generic/tclListObj.c
@@ -846,11 +846,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;
}