Code review request 6858865: Fix for 6728376 causes regression if the size of "data" is 0 and malloc returns Null for 0-length

Xueming Shen xueming.shen at
Fri Nov 19 23:18:35 UTC 2010


After staring those simple, 11 lines of change for minutes, I believe we 
should simply
go back with the original approach at

The change in

obviously is problematic, especially in case like in_len == 0 but 
out_len != 0 (no more,
or no more new input, but with a valid output buffer), it's definitely 
possible the
inflater/deflater might have more bites to (and should) output in this 
scenario, it's a
bug to return 0 here.

Sure it's possible to go further like

if (in_len == 0)
     return 0;

if (len == 0)

But given the purpose of this fix is to solve that particular 
"regression" (which actually
does not cause any regression for "mainstream" platforms), I prefer not 
take the risk
of causing another real regression/behavior change here, especially we 
got burned
couple times here in the past when tried to do better.



On 11/19/2010 02:03 PM, Xueming Shen wrote:
> On 11/19/2010 01:51 PM, Alan Bateman wrote:
>> Xueming Shen wrote:
>>> :
>>> Why do you want to feed the zlib with a null buffer? :-)
>> So are you saying that if the length is 0 that it still looks at the 
>> buffer? If so, then I'm okay with the last webrev.
> zlib does buffer null check before anything else, just like we do null 
> check/throw NPE first then
> check the offset and length.
> -Sherman

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the core-libs-dev mailing list