close file and don't malloc for no reason
This commit is contained in:
parent
e405ccdf2a
commit
2e57ca9b3f
1 changed files with 7 additions and 1 deletions
|
@ -44,7 +44,7 @@ const char *get(void) {
|
||||||
ssize_t read;
|
ssize_t read;
|
||||||
char *line = NULL;
|
char *line = NULL;
|
||||||
|
|
||||||
char *name = malloc(1024 * sizeof(char));
|
char *name = NULL;
|
||||||
const char *name_label = "PRETTY_NAME=";
|
const char *name_label = "PRETTY_NAME=";
|
||||||
const size_t name_label_len = strlen(name_label);
|
const size_t name_label_len = strlen(name_label);
|
||||||
|
|
||||||
|
@ -61,6 +61,12 @@ const char *get(void) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fclose(os_release);
|
||||||
|
|
||||||
|
if (name == NULL) {
|
||||||
|
name = "Unknown";
|
||||||
|
}
|
||||||
|
|
||||||
if (asprintf(&ret, "OS: %s", name) < 0) {
|
if (asprintf(&ret, "OS: %s", name) < 0) {
|
||||||
fprintf(stderr, "error: failed formatting string (this shouldn't happen)");
|
fprintf(stderr, "error: failed formatting string (this shouldn't happen)");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
Loading…
Reference in a new issue