mirror of
https://github.com/xzeldon/htop.git
synced 2024-12-24 15:15:44 +00:00
Avoid string overflow warning
Use xStrdup instead of xMallow and strncpy StringUtils.c: In function ‘String_split’: StringUtils.c:86:7: error: ‘strncpy’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=] 86 | strncpy(token, s, size + 1); | ^ StringUtils.c:84:18: note: length computed here 84 | int size = strlen(s); | ^
This commit is contained in:
parent
21fb56e1e2
commit
7457bfe9f3
@ -81,10 +81,7 @@ char** String_split(const char* s, char sep, int* n) {
|
||||
s += size + 1;
|
||||
}
|
||||
if (s[0] != '\0') {
|
||||
int size = strlen(s);
|
||||
char* token = xMalloc(size + 1);
|
||||
strncpy(token, s, size + 1);
|
||||
out[ctr] = token;
|
||||
out[ctr] = xStrdup(s);
|
||||
ctr++;
|
||||
}
|
||||
out = xRealloc(out, sizeof(char*) * (ctr + 1));
|
||||
|
Loading…
Reference in New Issue
Block a user