From 7c926553f6dcae359d48cc16d1ace1291a5dfb4b Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 8 Jun 2017 21:05:22 +0000 Subject: Modernize overflow checks. --- generic/tclStringObj.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 31a6b26..43f8016 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -2916,10 +2916,10 @@ TclStringCatObjv( last = objc - oc; if (length == 0) { first = last; - } - if ((length += numBytes) < 0) { + } else if (numBytes > INT_MAX - length) { goto overflow; } + length += numBytes; } } } while (--oc); @@ -2937,10 +2937,10 @@ TclStringCatObjv( last = objc - oc; if (length == 0) { first = last; - } - if ((length += numChars) < 0) { + } else if (numChars > INT_MAX - length) { goto overflow; } + length += numChars; } } } while (--oc); @@ -2973,10 +2973,10 @@ TclStringCatObjv( } if (length == 0) { first = last; - } - if ((length += numBytes) < 0) { + } else if (numBytes > INT_MAX - length) { goto overflow; } + length += numBytes; } } while (--oc); } -- cgit v0.12