mirror of https://github.com/xzeldon/htop.git
Avoid string overflow warning
Enough memory is allocated. Header.c: In function ‘Header_readMeterName’: Header.c:157:4: error: ‘strncpy’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=] 157 | strncpy(name, Meter_name(meter), nameLen); | ^ Header.c:154:18: note: length computed here 154 | int nameLen = strlen(Meter_name(meter)); | ^
This commit is contained in:
parent
6b11769448
commit
21fb56e1e2
2
Header.c
2
Header.c
|
@ -154,7 +154,7 @@ char* Header_readMeterName(Header* this, int i, int column) {
|
|||
int nameLen = strlen(Meter_name(meter));
|
||||
int len = nameLen + 100;
|
||||
char* name = xMalloc(len);
|
||||
strncpy(name, Meter_name(meter), nameLen);
|
||||
memcpy(name, Meter_name(meter), nameLen);
|
||||
name[nameLen] = '\0';
|
||||
if (meter->param)
|
||||
xSnprintf(name + nameLen, len - nameLen, "(%d)", meter->param);
|
||||
|
|
Loading…
Reference in New Issue