aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-10-30 02:02:01 +0100
committerThomas Voss <mail@thomasvoss.com> 2024-10-30 02:02:01 +0100
commitcacdc813439c25049730a149fdbc46b9dc4c834e (patch)
treed14d1576f446bd9f9689f8eaad25a86d6a257e2e /src/main.c
parent39a61f955b03820fd1a6653db68144d1b8021911 (diff)
Check for errors by getdelim()
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c4
1 files changed, 3 insertions, 1 deletions
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 *[]){"-"};