Fix a use after free()

The issue was reported by Coverity Scan.

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
This commit is contained in:
Ondřej Lysoněk authored and Guenter Roeck committed 2018-05-14 08:49:01 -07:00
1 parent 1c48b191c8
commit 3b548b74ae
1 file changed
+2 -2
+2 -2
View File
@@ -48,7 +48,6 @@ void print_chip_raw(const sensors_chip_name *name)
continue;
}
printf("%s:\n", label);
free(label);
b = 0;
while ((sub = sensors_get_all_subfeatures(name, feature, &b))) {
@@ -64,6 +63,7 @@ void print_chip_raw(const sensors_chip_name *name)
} else
printf("(%s)\n", label);
}
free(label);
}
}
@@ -86,7 +86,6 @@ void print_chip_json(const sensors_chip_name *name)
if (cnt > 0)
printf(",\n");
printf(" \"%s\":{\n", label);
free(label);
b = 0;
subCnt = 0;
@@ -109,6 +108,7 @@ void print_chip_json(const sensors_chip_name *name)
}
subCnt++;
}
free(label);
printf("\n }");
cnt++;
}