From 549fcb6bb8797a5fe981d484b84ffca23226655e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Sat, 30 Apr 2022 14:51:10 +0200 Subject: [PATCH] Always abort on overflow in String_cat Not only in debug mode. --- XUtils.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/XUtils.c b/XUtils.c index b34a8a73..2012b6c6 100644 --- a/XUtils.c +++ b/XUtils.c @@ -115,7 +115,9 @@ inline bool String_contains_i(const char* s1, const char* s2, bool multi) { char* String_cat(const char* s1, const char* s2) { const size_t l1 = strlen(s1); const size_t l2 = strlen(s2); - assert(SIZE_MAX - l1 > l2); + if (SIZE_MAX - l1 <= l2) { + fail(); + } char* out = xMalloc(l1 + l2 + 1); memcpy(out, s1, l1); memcpy(out + l1, s2, l2);