malloc failures in java/util/zip/Deflater

Roman Kennke Roman.Kennke at Sun.COM
Wed Jul 8 18:52:31 UTC 2009


Hi Mario,

> 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

I think NULL is returned in an out of memory situation, which is very
rare on modern OSes, but I think it's still possible. The right thing to
do here is check for NULL and (try to) throw an OOME. Which is what is
beeing done already (AFAICS). What are you trying to solve by
additionally checking for len > 0?

/Roman





More information about the core-libs-dev mailing list