summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2016-11-04 14:48:36 (GMT)
committerdgp <dgp@users.sourceforge.net>2016-11-04 14:48:36 (GMT)
commit885ced5608b51ed6815cd9afff4a9c47cfb1bd2d (patch)
tree3f9b95f9723fcea8b344a2efc4b391d84dd6b99d
parentb1fe66323bb9a2041ffc953d5fe96083c9534977 (diff)
downloadtcl-885ced5608b51ed6815cd9afff4a9c47cfb1bd2d.zip
tcl-885ced5608b51ed6815cd9afff4a9c47cfb1bd2d.tar.gz
tcl-885ced5608b51ed6815cd9afff4a9c47cfb1bd2d.tar.bz2
[824752f10e] More robust, portable check for integer overflow.
-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;
}