Re: [PATCH v3 3/6] unpack-objects: continue when fail to malloc due to large objects
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Aug 15, 2014, 05:24 UTC
- Message-ID
- <CACsJy8AF-NdAL-4t9k2-qrQCFFRC8T6==SvYiP14FktrxHEj=w@mail.gmail.com>
- In-Reply-To
- <xmqq7g2b2ele.fsf@gitster.dls.corp.google.com>
On Thu, Aug 14, 2014 at 11:58 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 13 quoted lines
>> +static void inflate_and_throw_away(unsigned long size)
>> +{
>
> But more importantly, the basic structure of this loop is the same
> as the loop we already have in the only caller of this new function,
> not just the regular "zlib produced this much that is not yet the
> expected size, go on reading more" and "we are at the end of the
> stream with Z_STREAM_END, and we are done", but even to "the stream
> is corrupt, we need to exit the loop", they are identical. Is a
> copy-and-paste like this the best we can do to add this "skip to the
> end of the current stream"? We would really want to keep the number
> of copies of this loop down; we saw a same bug introduced on the
> termination condition multiple times to different copies X-<.I know. I'm the author of one of those bugs. I considered updating the inflate loop in get_data() to support this throw-away mode but was afraid I may make the same mistake like in index-pack again. I'll probably drop this patch and think if I can unify inflate loop (for other places too, not just unpack-objects).
-- Duy