get_os_string either returns a string describing the distribution,
or NULL on error.
This NULL later causes problems since we run strlen on it.
This commit makes get_os_string return "" instead of NULL for error
cases.
Spotted by Andreas Henriksson.
char *buf, *pos, *pos2;
struct stat sbuf;
+ buf = NULL;
+
fd = open (RELEASE_FILE, O_RDONLY);
if (fd == -1)
- return;
+ goto out;
if (fstat (fd, &sbuf) == -1) {
close (fd);
- return;
+ goto out;
}
buf = calloc (sbuf.st_size + 1, sizeof(char));
out:
free (buf);
+
+ if (os_string == NULL)
+ os_string = strdup ("");
}
void