summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2007-10-03 23:25:10 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2007-10-04 00:42:30 +0100
commit66664596559c55913fb0b9c8784fe8ab862c217b (patch)
tree60e9e0232fbb0dec33e27c929498dd181fda693f /src
parente49bcde27f88e21d5b8037a0089a226096f6514b (diff)
[malloc] Take advantage of calloc() argument checking.
calloc() will check its arguments for integer overflows so it is safer not to pre-multiply them.
Diffstat (limited to 'src')
-rw-r--r--src/cairo-ft-font.c4
-rw-r--r--src/cairo-glitz-surface.c2
-rw-r--r--src/cairo-image-surface.c2
3 files changed, 4 insertions, 4 deletions
diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index 3262163fb..38a4a8dc5 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -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);
diff --git a/src/cairo-glitz-surface.c b/src/cairo-glitz-surface.c
index 8f497a9cc..4b0e74b2d 100644
--- a/src/cairo-glitz-surface.c
+++ b/src/cairo-glitz-surface.c
@@ -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);
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 645932928..9fbdb59a3 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -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;