[PATCH] bzip2recover: bsClose bsWr on early EOF
Mark Wielaard
mark@klomp.org
Thu Jun 11 21:20:32 GMT 2026
On Thu, May 28, 2026 at 07:31:28PM +0200, Mark Wielaard wrote:
> When getting an early EOF bsWr is never closed so any buffered output
> is leaked and never flushed out to the file.
Pushed.
> ---
> bzip2recover.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/bzip2recover.c b/bzip2recover.c
> index 6144284e6c04..e6c3dff3f950 100644
> --- a/bzip2recover.c
> +++ b/bzip2recover.c
> @@ -441,7 +441,12 @@ Int32 main ( Int32 argc, Char** argv )
> wrBlock = 0;
> while (True) {
> b = bsGetBit(bsIn);
> - if (b == 2) break;
> + if (b == 2) {
> + if (outFile != NULL) {
> + bsClose(bsWr);
> + }
> + break;
> + }
> buffHi = (buffHi << 1) | (buffLo >> 31);
> buffLo = (buffLo << 1) | (b & 1);
> if (bitsRead == 47+rbStart[wrBlock])
> --
> 2.54.0
>
More information about the Bzip2-devel
mailing list