[malloc] Take advantage of calloc() argument checking.

calloc() will check its arguments for integer overflows so it is safer
not to pre-multiply them.
This commit is contained in:
Chris Wilson 2007-10-03 23:25:10 +01:00
parent e49bcde27f
commit 6666459655
3 changed files with 4 additions and 4 deletions

View file

@ -840,7 +840,7 @@ _get_bitmap_surface (FT_Bitmap *bitmap,
width_rgba = width;
stride = bitmap->pitch;
stride_rgba = (width_rgba * 4 + 3) & ~3;
data_rgba = calloc (1, stride_rgba * height);
data_rgba = calloc (stride_rgba, height);
if (data_rgba == NULL) {
if (own_buffer)
free (bitmap->buffer);
@ -1041,7 +1041,7 @@ _render_glyph_outline (FT_Face face,
bitmap.pitch = stride;
bitmap.width = width * hmul;
bitmap.rows = height * vmul;
bitmap.buffer = calloc (1, stride * bitmap.rows);
bitmap.buffer = calloc (stride, bitmap.rows);
if (bitmap.buffer == NULL) {
_cairo_error (CAIRO_STATUS_NO_MEMORY);

View file

@ -1347,7 +1347,7 @@ _cairo_glitz_surface_composite_trapezoids (cairo_operator_t op,
int stride;
stride = (width + 3) & -4;
data = calloc (stride * height, 1);
data = calloc (stride, height);
if (!data)
{
_cairo_glitz_pattern_release_surface (src_pattern, src, &attributes);

View file

@ -1198,7 +1198,7 @@ _cairo_image_surface_composite_trapezoids (cairo_operator_t op,
}
/* The image must be initially transparent */
mask_data = calloc (1, mask_stride * height);
mask_data = calloc (mask_stride, height);
if (mask_data == NULL) {
status = CAIRO_STATUS_NO_MEMORY;
goto CLEANUP_SOURCE;