From 480c51780a02e0e4bb97435754100d850b948ffa Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 4 Nov 2016 14:48:36 +0000 Subject: [824752f10e] More robust, portable check for integer overflow. --- generic/tclListObj.c | 7 ++----- 1 file 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; } -- cgit v0.12