summaryrefslogtreecommitdiffstats
path: root/generic/tclListObj.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2010-03-18 20:34:47 (GMT)
committerdgp <dgp@users.sourceforge.net>2010-03-18 20:34:47 (GMT)
commiteb5c3529d6f7ce0af6006fd19ef2053042141731 (patch)
tree3e3228f8c83eb5503e48c4498d346f0f3a536d98 /generic/tclListObj.c
parent334db97a72461fd68bc9574ff8f6fc628cd40650 (diff)
downloadtcl-eb5c3529d6f7ce0af6006fd19ef2053042141731.zip
tcl-eb5c3529d6f7ce0af6006fd19ef2053042141731.tar.gz
tcl-eb5c3529d6f7ce0af6006fd19ef2053042141731.tar.bz2
* generic/tclListObj.c: Prevent in overflow trouble in [lreplace]
* generic/tclTestObj.c: operations. Thanks to kbk for fix and test. * tests/listObj.test: [Bug 2971669].
Diffstat (limited to 'generic/tclListObj.c')
-rw-r--r--generic/tclListObj.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/generic/tclListObj.c b/generic/tclListObj.c
index 896dcd3..6745f62 100644
--- a/generic/tclListObj.c
+++ b/generic/tclListObj.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclListObj.c,v 1.59 2010/02/24 14:30:34 dkf Exp $
+ * RCS: @(#) $Id: tclListObj.c,v 1.60 2010/03/18 20:34:48 dgp Exp $
*/
#include "tclInt.h"
@@ -832,7 +832,11 @@ Tcl_ListObjReplace(
}
if (count < 0) {
count = 0;
- } else if (numElems < first+count) {
+ } 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;
}