From 3be49723fced40ef581ccd12dbeb35b8cf346b12 Mon Sep 17 00:00:00 2001 From: dgp Date: Mon, 5 Feb 2018 13:41:26 +0000 Subject: Improved overflow prevention. --- generic/tclStringObj.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 8437555..c3a0192 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -190,8 +190,8 @@ GrowUnicodeBuffer( * Subsequent appends - apply the growth algorithm. */ - attempt = 2 * needed; - if (attempt >= 0 && attempt <= STRING_MAXCHARS) { + if (needed <= STRING_MAXCHARS / 2) { + attempt = 2 * needed; ptr = stringAttemptRealloc(stringPtr, attempt); } if (ptr == NULL) { -- cgit v0.12