mirror of https://github.com/xzeldon/htop.git
Always abort on overflow in String_cat
Not only in debug mode.
This commit is contained in:
parent
08166b27b1
commit
549fcb6bb8
4
XUtils.c
4
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);
|
||||
|
|
Loading…
Reference in New Issue