aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2025-11-26 16:06:42 -0500
committerB. Watson <urchlay@slackware.uk>2025-11-26 16:06:42 -0500
commit149441e5905ddacd5f771deb56a10f3b7c05f1fe (patch)
treecc292a01e42a8061f7bbf45bcaf6212a5e0f8a12
parent9e53a82e90ac85164c178e9c93ca47a74cd644ff (diff)
downloadunalf-149441e5905ddacd5f771deb56a10f3b7c05f1fe.tar.gz
alf: Don't try to compress 0-byte files.
-rw-r--r--src/alf.c9
1 files changed, 8 insertions, 1 deletions
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);