From 149441e5905ddacd5f771deb56a10f3b7c05f1fe Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Wed, 26 Nov 2025 16:06:42 -0500 Subject: alf: Don't try to compress 0-byte files. --- src/alf.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/alf.c b/src/alf.c index f77f8ad..bc38dd0 100644 --- a/src/alf.c +++ b/src/alf.c @@ -263,9 +263,16 @@ void crunch_file(const char *filename) { /* read in entire input, couldn't do it this way on the Atari */ input_len = fread(input_buf, 1, MAX_INPUT_SIZE - 1, in_file); + if(!feof(in_file)) { - fprintf(stderr, "%s: this file is too large; only compressing the first 16MB.\n", self); + fprintf(stderr, "%s: %s: this file is too large; only compressing the first 16MB.\n", self, filename); + } + + if(!input_len) { + fprintf(stderr, "%s: %s: can't compress a 0-byte (empty) file, skipping.\n", self, filename); + return; } + output_len = 0; fstat(fileno(in_file), &in_file_stat); /* for timestamp */ fclose(in_file); -- cgit v1.2.3