diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-10-30 02:02:01 +0100 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-10-30 02:02:01 +0100 |
commit | cacdc813439c25049730a149fdbc46b9dc4c834e (patch) | |
tree | d14d1576f446bd9f9689f8eaad25a86d6a257e2e | |
parent | 39a61f955b03820fd1a6653db68144d1b8021911 (diff) |
Check for errors by getdelim()
-rw-r--r-- | src/main.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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 *[]){"-"}; |