mirror of
https://github.com/xzeldon/htop.git
synced 2024-12-23 22:55:46 +00:00
Silence theoretical memory leak
In practice systemctl should never return multiple SystemState= lines.
This commit is contained in:
parent
fec9af4e6f
commit
f38af725c2
@ -206,8 +206,10 @@ static void updateViaExec(void) {
|
||||
while (fgets(lineBuffer, sizeof(lineBuffer), commandOutput)) {
|
||||
if (String_startsWith(lineBuffer, "SystemState=")) {
|
||||
char* newline = strchr(lineBuffer + strlen("SystemState="), '\n');
|
||||
if (newline)
|
||||
if (newline) {
|
||||
*newline = '\0';
|
||||
}
|
||||
free(systemState);
|
||||
systemState = xStrdup(lineBuffer + strlen("SystemState="));
|
||||
} else if (String_startsWith(lineBuffer, "NFailedUnits=")) {
|
||||
nFailedUnits = strtoul(lineBuffer + strlen("NFailedUnits="), NULL, 10);
|
||||
|
Loading…
Reference in New Issue
Block a user