mirror of https://github.com/xzeldon/htop.git
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)) {
|
while (fgets(lineBuffer, sizeof(lineBuffer), commandOutput)) {
|
||||||
if (String_startsWith(lineBuffer, "SystemState=")) {
|
if (String_startsWith(lineBuffer, "SystemState=")) {
|
||||||
char* newline = strchr(lineBuffer + strlen("SystemState="), '\n');
|
char* newline = strchr(lineBuffer + strlen("SystemState="), '\n');
|
||||||
if (newline)
|
if (newline) {
|
||||||
*newline = '\0';
|
*newline = '\0';
|
||||||
|
}
|
||||||
|
free(systemState);
|
||||||
systemState = xStrdup(lineBuffer + strlen("SystemState="));
|
systemState = xStrdup(lineBuffer + strlen("SystemState="));
|
||||||
} else if (String_startsWith(lineBuffer, "NFailedUnits=")) {
|
} else if (String_startsWith(lineBuffer, "NFailedUnits=")) {
|
||||||
nFailedUnits = strtoul(lineBuffer + strlen("NFailedUnits="), NULL, 10);
|
nFailedUnits = strtoul(lineBuffer + strlen("NFailedUnits="), NULL, 10);
|
||||||
|
|
Loading…
Reference in New Issue