diff options
Diffstat (limited to 'userspace/xzminidec.c')
-rw-r--r-- | userspace/xzminidec.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/userspace/xzminidec.c b/userspace/xzminidec.c index ba07413..b542109 100644 --- a/userspace/xzminidec.c +++ b/userspace/xzminidec.c @@ -61,10 +61,22 @@ int main(int argc, char **argv) while (true) { if (b.in_pos == b.in_size) { b.in_size = fread(in, 1, sizeof(in), stdin); + + if (ferror(stdin)) { + msg = "Read error\n"; + goto error; + } + b.in_pos = 0; } - ret = xz_dec_run(s, &b); + /* + * There are a few ways to set the "finish" (the third) + * argument. We could use feof(stdin) but testing in_size + * is fine too and may also work in applications that don't + * use FILEs. + */ + ret = xz_dec_catrun(s, &b, b.in_size == 0); if (b.out_pos == sizeof(out)) { if (fwrite(out, 1, b.out_pos, stdout) != b.out_pos) { |