summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2022-04-30 14:51:10 +0200
committerBenBE <BenBE@geshi.org>2022-05-05 09:19:14 +0200
commit549fcb6bb8797a5fe981d484b84ffca23226655e (patch)
tree671bc5201f1e26688283a01d12d28eea26ae3224
parent08166b27b191e7be62d74054d92a9720c3a141ab (diff)
Always abort on overflow in String_cat
Not only in debug mode.
-rw-r--r--XUtils.c4
1 files changed, 3 insertions, 1 deletions
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);

© 2014-2024 Faster IT GmbH | imprint | privacy policy