JDK-6858865 : Fix for 6728376 causes regression if the size of "data" is 0 and malloc returns Null for 0-length
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.jar
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2009-07-09
  • Updated: 2011-09-08
  • Resolved: 2011-05-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 6 JDK 7
5.0u33Fixed 6u27-revFixed 7 b121Fixed
Description
Hi all,

I've found a problem in the Deflater code in OpenJDK, where a length of zero bytes is passed to malloc.

According to the specs, malloc may return either a valid pointer that can be passed to free, or NULL, while generally NULL is considered to be a failure. Linux and Solaris, albeit non specifying it, return always a valid pointer, as far as I know, but I have a weird OS here that does indeed return NULL.

I've fixed this issue locally, and thought I could share the patch with you:

http://cr.openjdk.java.net/~neugens/deflater/webrev.00/

Cheers,
Mario

Comments
EVALUATION yes. 0 should always be returnted (instead of OOM) when the "data" size is 0.
09-07-2009