From cacdc813439c25049730a149fdbc46b9dc4c834e Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Wed, 30 Oct 2024 02:02:01 +0100 Subject: Check for errors by getdelim() --- src/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 895ffaa..3f96758 100644 --- a/src/main.c +++ b/src/main.c @@ -148,13 +148,15 @@ main(int argc, char **argv) size_t len; ssize_t nr; char *file = nullptr; - while ((nr = getdelim(&file, &len, 0, fstream)) > 0) { + while ((nr = getdelim(&file, &len, 0, fstream)) != -1) { /* TODO: Would an arena improve performance? */ const char *s = strdup(file); if (s == nullptr) cerr(EXIT_FATAL, "strdup:"); array_push(&filenames, s); } + if (ferror(fstream)) + cerr(EXIT_FATAL, "getdelim:"); #else if (argc == 1) argv = (static char *[]){"-"}; -- cgit v1.2.3