markman

markdown man page converter
git clone git://edryd.org/markman
Log | Files | Refs | LICENSE

commit 229a62c2e4c77c47361c09373afaeeae12e3b382
parent 5edc1eae583271b57b98b84f1a8137296aecb463
Author: Ed van Bruggen <edvb@uw.edu>
Date:   Fri,  7 Jan 2022 19:50:52 -0800

Fix file reading

Diffstat:
Mmarkman.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/markman.c b/markman.c @@ -376,7 +376,7 @@ static char* str_file(int fd) { char buf[BUFSIZ], *file = NULL; - int len, n; + int len = 0, n; while ((n = read(fd, buf, sizeof(buf))) > 0) { file = realloc(file, len + n + 1); if (!file) die(1, "realloc:"); @@ -384,7 +384,7 @@ str_file(int fd) len += n; file[len] = '\0'; } - if (fd != 0) + if (fd) close(fd); if (n < 0) die(1, "read:");