diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2012-06-14 10:33:01 +0300 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2012-06-14 10:33:01 +0300 |
commit | 905f0ab5b5ce544d4b68a2ed6077df0f3d021292 (patch) | |
tree | 9d55fd56df7047a911a4649c1b9396b75ced08a3 | |
parent | Translations: Update the French translation. (diff) | |
download | xz-905f0ab5b5ce544d4b68a2ed6077df0f3d021292.tar.xz |
Docs: Fix a bug in xz_pipe_decomp.c example program.
-rw-r--r-- | doc/examples/xz_pipe_decomp.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/doc/examples/xz_pipe_decomp.c b/doc/examples/xz_pipe_decomp.c index d4b204d7..fb5ad895 100644 --- a/doc/examples/xz_pipe_decomp.c +++ b/doc/examples/xz_pipe_decomp.c @@ -1,7 +1,7 @@ /* * xz_pipe_decomp.c * A simple example of pipe-only xz decompressor implementation. - * version: 2010-07-12 - by Daniel Mealha Cabrita + * version: 2012-06-14 - by Daniel Mealha Cabrita * Not copyrighted -- provided to the public domain. * * Compiling: @@ -101,6 +101,14 @@ int xz_decompress (FILE *in_file, FILE *out_file) } while (strm.avail_out == 0); } + /* Bug fix (2012-06-14): If no errors were detected, check + that the last lzma_code() call returned LZMA_STREAM_END. + If not, the file is probably truncated. */ + if ((ret == RET_OK) && (ret_xz != LZMA_STREAM_END)) { + fprintf (stderr, "Input truncated or corrupt\n"); + ret = RET_ERROR_DECOMPRESSION; + } + lzma_end (&strm); return ret; } |