commit a246f8329e0578ed046afa0b75e46a41395a0fa1
parent dc7962fb6c7be827be3056bc46ce0b646ff3927d
Author: sam-barr <samfbarr@outlook.com>
Date: Thu, 23 Apr 2020 16:08:04 -0500
error handling in get_os
Diffstat:
1 file changed, 4 insertions(+), 0 deletions(-)
diff --git a/paleofetch.c b/paleofetch.c
@@ -106,6 +106,10 @@ char *get_os() {
char *os = malloc(BUF_SIZE),
*name = malloc(BUF_SIZE);
FILE *os_release = fopen("/etc/os-release", "r");
+ if(os_release == NULL) {
+ status = -1;
+ halt_and_catch_fire("unable to open /etc/os-release");
+ }
fscanf(os_release, "NAME=\"%[^\"]+", name);
fclose(os_release);