[PATCH] Don't try to malloc a zero sized list
torvalds at linux-foundation.org
Thu Dec 11 23:19:33 PST 2014
On Dec 11, 2014 11:07 PM, "Anton Lundin" <glance at acc.umu.se> wrote:
> So, should the right approach here be not to trust malloc returning NULL
> here and we explicitly set sample to null if s->samples == 0 ?
That sounds fine, yes.
Or just initialize the fields to zero/NULL and then do that
with the properly initialized state
> Another thought, taken how the current copy_samples looks, if you where
> to call prepare_sample(d) after a copy_samples(s, d), which copied more
> than 10 samples, too me it looks like prepare_sample would truncate the
> sample list because copy_samples doesn't set dc->alloc_samples.
On mobile right now, so I can't check, but yes, initializing alloc_samples
to the allocation size sounds right to me.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the subsurface