diff --git a/modules/os.c b/modules/os.c index d32c610..2082759 100644 --- a/modules/os.c +++ b/modules/os.c @@ -44,7 +44,7 @@ const char *get(void) { ssize_t read; char *line = NULL; - char *name = malloc(1024 * sizeof(char)); + char *name = NULL; const char *name_label = "PRETTY_NAME="; const size_t name_label_len = strlen(name_label); @@ -61,6 +61,12 @@ const char *get(void) { break; } + fclose(os_release); + + if (name == NULL) { + name = "Unknown"; + } + if (asprintf(&ret, "OS: %s", name) < 0) { fprintf(stderr, "error: failed formatting string (this shouldn't happen)"); exit(EXIT_FAILURE);