Eric Blake wrote:
On 05/20/2010 02:45 PM, Jim Fehlig wrote:
> +virBitmapPtr virBitmapAlloc(size_t size)
> +{
> + virBitmapPtr bitmap;
> + size_t sz = (size + VIR_BITMAP_BITS_PER_UNIT - 1) /
> + VIR_BITMAP_BITS_PER_UNIT;
>
Check for overflow:
if (SIZE_MAX - VIR_BITMAP_BITS_PER_UNIT < size)
return NULL;
> +
> + if (VIR_ALLOC_N(bitmap, sizeof(virBitmap)) < 0)
>
Use VIR_ALLOC(bitmap) - you want to allocate one bitmap object, not an
array of bitmaps of length 'sizeof(virBitmap)'.
Opps. Copy and paste from bitmap->map.
This and your other comments are addressed in V3.
Regards,
Jim