From 9851c5ea3410589dadfc43e809fd65ee66b58d28 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 20 May 2026 08:32:41 -0700 Subject: [PATCH] Shrink STRING_BYTES_MAX slightly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * src/alloc.c (STRING_BYTES_MAX): Also don’t allow sizes to exceed PTRDIFF_MAX in internal calculations when calling malloc, as those are problematic even if the final number of bytes does not exceed PTRDIFF_MAX. --- src/alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/alloc.c b/src/alloc.c index a73e7df1dc7..387b196bbee 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -1501,7 +1501,7 @@ sdata_size (ptrdiff_t n) calculating a value to be passed to malloc. */ static ptrdiff_t const STRING_BYTES_MAX = min (STRING_BYTES_BOUND, - ((SIZE_MAX + ((min (PTRDIFF_MAX, SIZE_MAX) - GC_STRING_EXTRA - offsetof (struct sblock, data) - SDATA_DATA_OFFSET)