8278794: Infinite loop in DeflaterOutputStream.finish()

Reviewed-by: coffeys, lancea
This commit is contained in:
Ravi Reddy 2022-03-18 15:31:30 +00:00 committed by Lance Andersen
parent b2aa085e67
commit ff0b0927a2
5 changed files with 231 additions and 154 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -314,7 +314,7 @@ public class ZipOutputStream extends DeflaterOutputStream implements ZipConstant
crc.reset();
current = null;
} catch (IOException e) {
if (usesDefaultDeflater && !(e instanceof ZipException))
if (def.shouldFinish() && usesDefaultDeflater && !(e instanceof ZipException))
def.end();
throw e;
}