mirror of https://github.com/xzeldon/htop.git
Ensure result buffer termination in String_cat utility routine
This commit is contained in:
parent
74d547674d
commit
5228f5d47a
|
@ -30,8 +30,9 @@ char* String_cat(const char* s1, const char* s2) {
|
||||||
int l1 = strlen(s1);
|
int l1 = strlen(s1);
|
||||||
int l2 = strlen(s2);
|
int l2 = strlen(s2);
|
||||||
char* out = xMalloc(l1 + l2 + 1);
|
char* out = xMalloc(l1 + l2 + 1);
|
||||||
strncpy(out, s1, l1);
|
memcpy(out, s1, l1);
|
||||||
strncpy(out+l1, s2, l2+1);
|
memcpy(out+l1, s2, l2+1);
|
||||||
|
out[l1 + l2] = '\0';
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue