3 commits - src/cairo-cff-subset.c src/cairo-clip-tor-scan-converter.c src/cairo-colr-glyph-render.c src/cairo-ft-font.c src/cairo-hash.c src/cairo-malloc-private.h src/cairo-mempool.c src/cairo-pdf-interchange.c src/cairo-pdf-surface.c src/cairo-ps-surface.c src/cairo-raster-source-pattern.c src/cairo-recording-surface.c src/cairo-scaled-font-subsets.c src/cairo-tag-attributes.c src/cairo-truetype-subset.c src/cairo-type1-fallback.c src/cairo-type1-subset.c src/cairo-xcb-connection.c src/win32
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri May 24 21:44:21 UTC 2024
src/cairo-cff-subset.c | 48 ++++++++++++++++---------------
src/cairo-clip-tor-scan-converter.c | 2 -
src/cairo-colr-glyph-render.c | 4 +-
src/cairo-ft-font.c | 4 +-
src/cairo-hash.c | 4 +-
src/cairo-malloc-private.h | 16 ++++++++++
src/cairo-mempool.c | 2 -
src/cairo-pdf-interchange.c | 8 ++---
src/cairo-pdf-surface.c | 2 -
src/cairo-ps-surface.c | 2 -
src/cairo-raster-source-pattern.c | 2 -
src/cairo-recording-surface.c | 4 +-
src/cairo-scaled-font-subsets.c | 2 -
src/cairo-tag-attributes.c | 2 -
src/cairo-truetype-subset.c | 8 ++---
src/cairo-type1-fallback.c | 8 ++---
src/cairo-type1-subset.c | 8 ++---
src/cairo-xcb-connection.c | 2 -
src/win32/cairo-win32-printing-surface.c | 2 -
19 files changed, 75 insertions(+), 55 deletions(-)
New commits:
commit 212f4589496cc96f08d19f05791b0ad9cfcf3d6d
Merge: 1f0b80ed5 d465f4491
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Fri May 24 21:44:13 2024 +0000
Merge branch 'cff-global-subs-fix' into 'master'
CFF Fix crash when allocating zero size array
See merge request cairo/cairo!553
commit d465f44911c3891cc07bca12567293093ab93e9c
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Tue May 21 20:38:20 2024 +0930
cff: Don't try allocating a zero sized array
diff --git a/src/cairo-cff-subset.c b/src/cairo-cff-subset.c
index a4c3b130d..6cc2ab4f5 100644
--- a/src/cairo-cff-subset.c
+++ b/src/cairo-cff-subset.c
@@ -1314,9 +1314,13 @@ cairo_cff_font_read_global_subroutines (cairo_cff_font_t *font)
return status;
num_subs = _cairo_array_num_elements (&font->global_sub_index);
- font->global_subs_used = _cairo_calloc (num_subs, sizeof(cairo_bool_t));
- if (unlikely (font->global_subs_used == NULL))
- return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ if (num_subs > 0) {
+ font->global_subs_used = _cairo_calloc (num_subs, sizeof(cairo_bool_t));
+ if (unlikely (font->global_subs_used == NULL))
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ } else {
+ font->global_subs_used = NULL;
+ }
if (num_subs < 1240)
font->global_sub_bias = 107;
commit 3715d93bdf997f5f2209294e38c628ee08c5a799
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Tue May 21 20:13:59 2024 +0930
Create _cairo_calloc() macro to replace calloc()
Not all platforms handle a zero sized allocation in calloc the
same. This macro ensures that _cairo_calloc(0) always returns NULL
similar to _cairo_malloc(0).
diff --git a/src/cairo-cff-subset.c b/src/cairo-cff-subset.c
index 284eb8df1..a4c3b130d 100644
--- a/src/cairo-cff-subset.c
+++ b/src/cairo-cff-subset.c
@@ -952,7 +952,7 @@ cairo_cff_font_read_private_dict (cairo_cff_font_t *font,
decode_number (operand, nominal_width);
num_subs = _cairo_array_num_elements (local_sub_index);
- *local_subs_used = calloc (num_subs, sizeof (cairo_bool_t));
+ *local_subs_used = _cairo_calloc (num_subs, sizeof (cairo_bool_t));
if (unlikely (*local_subs_used == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -971,7 +971,7 @@ cairo_cff_font_read_fdselect (cairo_cff_font_t *font, unsigned char *p)
{
int type, num_ranges, first, last, fd, i, j;
- font->fdselect = calloc (font->num_glyphs, sizeof (int));
+ font->fdselect = _cairo_calloc (font->num_glyphs, sizeof (int));
if (unlikely (font->fdselect == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -1021,43 +1021,43 @@ cairo_cff_font_read_cid_fontdict (cairo_cff_font_t *font, unsigned char *ptr)
font->num_fontdicts = _cairo_array_num_elements (&index);
- font->fd_dict = calloc (font->num_fontdicts, sizeof (cairo_hash_table_t *));
+ font->fd_dict = _cairo_calloc (font->num_fontdicts, sizeof (cairo_hash_table_t *));
if (unlikely (font->fd_dict == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail;
}
- font->fd_private_dict = calloc (font->num_fontdicts, sizeof (cairo_hash_table_t *));
+ font->fd_private_dict = _cairo_calloc (font->num_fontdicts, sizeof (cairo_hash_table_t *));
if (unlikely (font->fd_private_dict == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail;
}
- font->fd_local_sub_index = calloc (font->num_fontdicts, sizeof (cairo_array_t));
+ font->fd_local_sub_index = _cairo_calloc (font->num_fontdicts, sizeof (cairo_array_t));
if (unlikely (font->fd_local_sub_index == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail;
}
- font->fd_local_sub_bias = calloc (font->num_fontdicts, sizeof (int));
+ font->fd_local_sub_bias = _cairo_calloc (font->num_fontdicts, sizeof (int));
if (unlikely (font->fd_local_sub_bias == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail;
}
- font->fd_local_subs_used = calloc (font->num_fontdicts, sizeof (cairo_bool_t *));
+ font->fd_local_subs_used = _cairo_calloc (font->num_fontdicts, sizeof (cairo_bool_t *));
if (unlikely (font->fd_local_subs_used == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail;
}
- font->fd_default_width = calloc (font->num_fontdicts, sizeof (double));
+ font->fd_default_width = _cairo_calloc (font->num_fontdicts, sizeof (double));
if (unlikely (font->fd_default_width == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail;
}
- font->fd_nominal_width = calloc (font->num_fontdicts, sizeof (double));
+ font->fd_nominal_width = _cairo_calloc (font->num_fontdicts, sizeof (double));
if (unlikely (font->fd_nominal_width == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail;
@@ -1314,7 +1314,7 @@ cairo_cff_font_read_global_subroutines (cairo_cff_font_t *font)
return status;
num_subs = _cairo_array_num_elements (&font->global_sub_index);
- font->global_subs_used = calloc (num_subs, sizeof(cairo_bool_t));
+ font->global_subs_used = _cairo_calloc (num_subs, sizeof(cairo_bool_t));
if (unlikely (font->global_subs_used == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -1832,20 +1832,20 @@ cairo_cff_font_subset_fontdict (cairo_cff_font_t *font)
unsigned long cid, gid;
cairo_int_status_t status;
- font->fdselect_subset = calloc (font->scaled_font_subset->num_glyphs,
+ font->fdselect_subset = _cairo_calloc (font->scaled_font_subset->num_glyphs,
sizeof (int));
if (unlikely (font->fdselect_subset == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
- font->fd_subset_map = calloc (font->num_fontdicts, sizeof (int));
+ font->fd_subset_map = _cairo_calloc (font->num_fontdicts, sizeof (int));
if (unlikely (font->fd_subset_map == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
- font->private_dict_offset = calloc (font->num_fontdicts, sizeof (int));
+ font->private_dict_offset = _cairo_calloc (font->num_fontdicts, sizeof (int));
if (unlikely (font->private_dict_offset == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
- reverse_map = calloc (font->num_fontdicts, sizeof (int));
+ reverse_map = _cairo_calloc (font->num_fontdicts, sizeof (int));
if (unlikely (reverse_map == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -2810,7 +2810,7 @@ _cairo_cff_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
return CAIRO_INT_STATUS_UNSUPPORTED;
}
- font = calloc (1, sizeof (cairo_cff_font_t));
+ font = _cairo_calloc (1, sizeof (cairo_cff_font_t));
if (unlikely (font == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -2835,7 +2835,7 @@ _cairo_cff_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
goto fail2;
}
- font->widths = calloc (font->scaled_font_subset->num_glyphs, sizeof (int));
+ font->widths = _cairo_calloc (font->scaled_font_subset->num_glyphs, sizeof (int));
if (unlikely (font->widths == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail3;
@@ -2994,7 +2994,7 @@ _cairo_cff_subset_init (cairo_cff_subset_t *cff_subset,
cff_subset->family_name_utf8 = NULL;
}
- cff_subset->widths = calloc (font->scaled_font_subset->num_glyphs, sizeof (double));
+ cff_subset->widths = _cairo_calloc (font->scaled_font_subset->num_glyphs, sizeof (double));
if (unlikely (cff_subset->widths == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail3;
@@ -3160,7 +3160,7 @@ _cairo_cff_font_fallback_create (cairo_scaled_font_subset_t *scaled_font_subset
cairo_status_t status;
cairo_cff_font_t *font;
- font = calloc (1, sizeof (cairo_cff_font_t));
+ font = _cairo_calloc (1, sizeof (cairo_cff_font_t));
if (unlikely (font == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -3192,7 +3192,7 @@ _cairo_cff_font_fallback_create (cairo_scaled_font_subset_t *scaled_font_subset
font->ascent = 0;
font->descent = 0;
- font->widths = calloc (font->scaled_font_subset->num_glyphs, sizeof (int));
+ font->widths = _cairo_calloc (font->scaled_font_subset->num_glyphs, sizeof (int));
if (unlikely (font->widths == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail3;
@@ -3407,7 +3407,7 @@ _cairo_cff_fallback_init (cairo_cff_subset_t *cff_subset,
goto fail2;
}
- cff_subset->widths = calloc (font->scaled_font_subset->num_glyphs, sizeof (double));
+ cff_subset->widths = _cairo_calloc (font->scaled_font_subset->num_glyphs, sizeof (double));
if (unlikely (cff_subset->widths == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail3;
diff --git a/src/cairo-clip-tor-scan-converter.c b/src/cairo-clip-tor-scan-converter.c
index 2ac1d32b1..f347c764e 100644
--- a/src/cairo-clip-tor-scan-converter.c
+++ b/src/cairo-clip-tor-scan-converter.c
@@ -1794,7 +1794,7 @@ _cairo_clip_tor_scan_converter_create (cairo_clip_t *clip,
cairo_status_t status;
int i;
- self = calloc (1, sizeof(struct _cairo_clip_tor_scan_converter));
+ self = _cairo_calloc (1, sizeof(struct _cairo_clip_tor_scan_converter));
if (unlikely (self == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto bail_nomem;
diff --git a/src/cairo-colr-glyph-render.c b/src/cairo-colr-glyph-render.c
index 89e27354b..05e3da29d 100644
--- a/src/cairo-colr-glyph-render.c
+++ b/src/cairo-colr-glyph-render.c
@@ -327,12 +327,12 @@ read_colorline (cairo_colr_glyph_render_t *render,
double colr_alpha;
cairo_bool_t is_foreground_color;
- cl = calloc (1, sizeof (cairo_colr_color_line_t));
+ cl = _cairo_calloc (1, sizeof (cairo_colr_color_line_t));
if (unlikely (cl == NULL))
return NULL;
cl->n_stops = colorline->color_stop_iterator.num_color_stops;
- cl->stops = calloc (cl->n_stops, sizeof (cairo_colr_color_stop_t));
+ cl->stops = _cairo_calloc (cl->n_stops, sizeof (cairo_colr_color_stop_t));
if (unlikely (cl->stops == NULL)) {
free (cl);
return NULL;
diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index 214fd348e..7d9da2f96 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -499,7 +499,7 @@ _cairo_ft_unscaled_font_init (cairo_ft_unscaled_font_t *unscaled,
FT_MM_Var *ft_mm_var;
if (0 == FT_Get_MM_Var (face, &ft_mm_var))
{
- unscaled->variations = calloc (ft_mm_var->num_axis, sizeof (FT_Fixed));
+ unscaled->variations = _cairo_calloc (ft_mm_var->num_axis, sizeof (FT_Fixed));
if (unscaled->variations)
FT_Get_Var_Design_Coordinates (face, ft_mm_var->num_axis, unscaled->variations);
#if HAVE_FT_DONE_MM_VAR
@@ -1601,7 +1601,7 @@ _render_glyph_outline (FT_Face face,
if (bitmap_size < 0)
return _cairo_error (CAIRO_STATUS_INVALID_FORMAT);
- bitmap.buffer = calloc (1, bitmap_size);
+ bitmap.buffer = _cairo_calloc (1, bitmap_size);
if (bitmap.buffer == NULL)
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-hash.c b/src/cairo-hash.c
index a3cc452b7..8a6772506 100644
--- a/src/cairo-hash.c
+++ b/src/cairo-hash.c
@@ -178,7 +178,7 @@ _cairo_hash_table_create (cairo_hash_keys_equal_func_t keys_equal)
memset (&hash_table->cache, 0, sizeof (hash_table->cache));
hash_table->table_size = &hash_table_sizes[0];
- hash_table->entries = calloc (*hash_table->table_size,
+ hash_table->entries = _cairo_calloc (*hash_table->table_size,
sizeof (cairo_hash_entry_t *));
if (unlikely (hash_table->entries == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
@@ -304,7 +304,7 @@ _cairo_hash_table_manage (cairo_hash_table_t *hash_table)
}
new_size = *tmp.table_size;
- tmp.entries = calloc (new_size, sizeof (cairo_hash_entry_t*));
+ tmp.entries = _cairo_calloc (new_size, sizeof (cairo_hash_entry_t*));
if (unlikely (tmp.entries == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-malloc-private.h b/src/cairo-malloc-private.h
index 0de52a561..f7c1ac914 100644
--- a/src/cairo-malloc-private.h
+++ b/src/cairo-malloc-private.h
@@ -62,6 +62,22 @@
#define _cairo_malloc(size) \
((size) != 0 ? malloc(size) : NULL)
+/**
+ * _cairo_calloc:
+ * @a: number of elements to allocate
+ * @size: size of each element
+ *
+ * Allocates @a*@size memory using calloc().
+ * The memory should be freed using free().
+ * calloc is skipped, if 0 bytes are requested, and %NULL will be returned.
+ *
+ * Return value: A pointer to the newly allocated memory, or %NULL in
+ * case of calloc() failure or overflow.
+ **/
+
+#define _cairo_calloc(a, size) \
+ ((((a) != 0) && ((size) != 0)) ? calloc(a, size) : NULL)
+
/**
* _cairo_malloc_ab:
* @a: number of elements to allocate
diff --git a/src/cairo-mempool.c b/src/cairo-mempool.c
index dd4756261..04077edcb 100644
--- a/src/cairo-mempool.c
+++ b/src/cairo-mempool.c
@@ -305,7 +305,7 @@ _cairo_mempool_init (cairo_mempool_t *pool,
pool->max_free_bits = -1;
num_blocks = bytes >> min_bits;
- pool->blocks = calloc (num_blocks, sizeof (struct _cairo_memblock));
+ pool->blocks = _cairo_calloc (num_blocks, sizeof (struct _cairo_memblock));
if (pool->blocks == NULL)
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-pdf-interchange.c b/src/cairo-pdf-interchange.c
index 6bda9e8b8..8c879a99a 100644
--- a/src/cairo-pdf-interchange.c
+++ b/src/cairo-pdf-interchange.c
@@ -1583,7 +1583,7 @@ _cairo_pdf_interchange_write_document_dests (cairo_pdf_surface_t *surface)
return CAIRO_STATUS_SUCCESS;
}
- ic->sorted_dests = calloc (ic->num_dests, sizeof (cairo_pdf_named_dest_t *));
+ ic->sorted_dests = _cairo_calloc (ic->num_dests, sizeof (cairo_pdf_named_dest_t *));
if (unlikely (ic->sorted_dests == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -1838,7 +1838,7 @@ _cairo_pdf_interchange_begin_dest_tag (cairo_pdf_surface_t *surface,
cairo_int_status_t status = CAIRO_STATUS_SUCCESS;
if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE) {
- dest = calloc (1, sizeof (cairo_pdf_named_dest_t));
+ dest = _cairo_calloc (1, sizeof (cairo_pdf_named_dest_t));
if (unlikely (dest == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -2431,7 +2431,7 @@ _cairo_pdf_interchange_init (cairo_pdf_surface_t *surface)
_cairo_tag_stack_init (&ic->analysis_tag_stack);
_cairo_tag_stack_init (&ic->render_tag_stack);
- ic->struct_root = calloc (1, sizeof(cairo_pdf_struct_tree_node_t));
+ ic->struct_root = _cairo_calloc (1, sizeof(cairo_pdf_struct_tree_node_t));
if (unlikely (ic->struct_root == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -2475,7 +2475,7 @@ _cairo_pdf_interchange_init (cairo_pdf_surface_t *surface)
ic->mcid_order = 0;
_cairo_array_init (&ic->outline, sizeof(cairo_pdf_outline_entry_t *));
- outline_root = calloc (1, sizeof(cairo_pdf_outline_entry_t));
+ outline_root = _cairo_calloc (1, sizeof(cairo_pdf_outline_entry_t));
if (unlikely (outline_root == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index d4c6e39d9..e94f19013 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -1402,7 +1402,7 @@ _cairo_pdf_surface_create_smask_group (cairo_pdf_surface_t *surface,
{
cairo_pdf_smask_group_t *group;
- group = calloc (1, sizeof (cairo_pdf_smask_group_t));
+ group = _cairo_calloc (1, sizeof (cairo_pdf_smask_group_t));
if (unlikely (group == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index ad52918c2..cdf06344d 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -3521,7 +3521,7 @@ _cairo_ps_surface_use_form (cairo_ps_surface_t *surface,
unique_id_length = source_key.unique_id_length;
memcpy (unique_id, source_key.unique_id, unique_id_length);
- source_entry = calloc (1, sizeof (cairo_ps_form_t));
+ source_entry = _cairo_calloc (1, sizeof (cairo_ps_form_t));
if (source_entry == NULL) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail;
diff --git a/src/cairo-raster-source-pattern.c b/src/cairo-raster-source-pattern.c
index 64520feae..e657e5c61 100644
--- a/src/cairo-raster-source-pattern.c
+++ b/src/cairo-raster-source-pattern.c
@@ -168,7 +168,7 @@ cairo_pattern_create_raster_source (void *user_data,
if (! CAIRO_CONTENT_VALID (content))
return _cairo_pattern_create_in_error (CAIRO_STATUS_INVALID_CONTENT);
- pattern = calloc (1, sizeof (*pattern));
+ pattern = _cairo_calloc (1, sizeof (*pattern));
if (unlikely (pattern == NULL))
return _cairo_pattern_create_in_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-recording-surface.c b/src/cairo-recording-surface.c
index 23e98c6db..8f3831842 100644
--- a/src/cairo-recording-surface.c
+++ b/src/cairo-recording-surface.c
@@ -1193,7 +1193,7 @@ _cairo_recording_surface_tag (void *abstract_surface,
surface->has_tags = TRUE;
- command = calloc (1, sizeof (cairo_command_tag_t));
+ command = _cairo_calloc (1, sizeof (cairo_command_tag_t));
if (unlikely (command == NULL)) {
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
@@ -1516,7 +1516,7 @@ _cairo_recording_surface_copy__tag (cairo_recording_surface_t *surface,
cairo_command_tag_t *command;
cairo_status_t status;
- command = calloc (1, sizeof (*command));
+ command = _cairo_calloc (1, sizeof (*command));
if (unlikely (command == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto err;
diff --git a/src/cairo-scaled-font-subsets.c b/src/cairo-scaled-font-subsets.c
index a240bebbe..e573c530b 100644
--- a/src/cairo-scaled-font-subsets.c
+++ b/src/cairo-scaled-font-subsets.c
@@ -1238,7 +1238,7 @@ _cairo_scaled_font_subset_create_glyph_names (cairo_scaled_font_subset_t *subset
if (unlikely (names == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
- subset->glyph_names = calloc (subset->num_glyphs, sizeof (char *));
+ subset->glyph_names = _cairo_calloc (subset->num_glyphs, sizeof (char *));
if (unlikely (subset->glyph_names == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto CLEANUP_HASH;
diff --git a/src/cairo-tag-attributes.c b/src/cairo-tag-attributes.c
index 7873bb8da..8c305e3cc 100644
--- a/src/cairo-tag-attributes.c
+++ b/src/cairo-tag-attributes.c
@@ -432,7 +432,7 @@ parse_attributes (const char *attributes, const attribute_spec_t *attrib_def, ca
goto fail1;
}
- attrib = calloc (1, sizeof (attribute_t));
+ attrib = _cairo_calloc (1, sizeof (attribute_t));
if (unlikely (attrib == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail1;
diff --git a/src/cairo-truetype-subset.c b/src/cairo-truetype-subset.c
index 42fbffb40..7f9a075aa 100644
--- a/src/cairo-truetype-subset.c
+++ b/src/cairo-truetype-subset.c
@@ -212,14 +212,14 @@ _cairo_truetype_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
/* Add 2: +1 case font does not contain .notdef, and +1 because an extra
* entry is required to contain the end location of the last glyph.
*/
- font->glyphs = calloc (font->base.num_glyphs_in_face + 2, sizeof (subset_glyph_t));
+ font->glyphs = _cairo_calloc (font->base.num_glyphs_in_face + 2, sizeof (subset_glyph_t));
if (unlikely (font->glyphs == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail1;
}
/* Add 1 in case font does not contain .notdef */
- font->parent_to_subset = calloc (font->base.num_glyphs_in_face + 1, sizeof (int));
+ font->parent_to_subset = _cairo_calloc (font->base.num_glyphs_in_face + 1, sizeof (int));
if (unlikely (font->parent_to_subset == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail2;
@@ -259,7 +259,7 @@ _cairo_truetype_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
}
/* Add 1 in case font does not contain .notdef */
- font->widths = calloc (font->base.num_glyphs_in_face + 1, sizeof (int));
+ font->widths = _cairo_calloc (font->base.num_glyphs_in_face + 1, sizeof (int));
if (unlikely (font->widths == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail4;
@@ -1181,7 +1181,7 @@ cairo_truetype_subset_init_internal (cairo_truetype_subset_t *truetype_subse
/* The widths array returned must contain only widths for the
* glyphs in font_subset. Any subglyphs appended after
* font_subset->num_glyphs are omitted. */
- truetype_subset->widths = calloc (font->scaled_font_subset->num_glyphs, sizeof (double));
+ truetype_subset->widths = _cairo_calloc (font->scaled_font_subset->num_glyphs, sizeof (double));
if (unlikely (truetype_subset->widths == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail3;
diff --git a/src/cairo-type1-fallback.c b/src/cairo-type1-fallback.c
index 5b4223b25..3abcd7e19 100644
--- a/src/cairo-type1-fallback.c
+++ b/src/cairo-type1-fallback.c
@@ -88,11 +88,11 @@ cairo_type1_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
cairo_font_options_t font_options;
cairo_status_t status;
- font = calloc (1, sizeof (cairo_type1_font_t));
+ font = _cairo_calloc (1, sizeof (cairo_type1_font_t));
if (unlikely (font == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
- font->widths = calloc (scaled_font_subset->num_glyphs, sizeof (int));
+ font->widths = _cairo_calloc (scaled_font_subset->num_glyphs, sizeof (int));
if (unlikely (font->widths == NULL)) {
free (font);
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -747,7 +747,7 @@ _cairo_type1_fallback_init_internal (cairo_type1_subset_t *type1_subset,
goto fail1;
}
- type1_subset->widths = calloc (font->scaled_font_subset->num_glyphs, sizeof (double));
+ type1_subset->widths = _cairo_calloc (font->scaled_font_subset->num_glyphs, sizeof (double));
if (unlikely (type1_subset->widths == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail2;
@@ -841,7 +841,7 @@ _cairo_type2_charstrings_init (cairo_type2_charstrings_t *type2_subset,
_cairo_array_init (&type2_subset->charstrings, sizeof (cairo_array_t));
- type2_subset->widths = calloc (font->scaled_font_subset->num_glyphs, sizeof (int));
+ type2_subset->widths = _cairo_calloc (font->scaled_font_subset->num_glyphs, sizeof (int));
if (unlikely (type2_subset->widths == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail1;
diff --git a/src/cairo-type1-subset.c b/src/cairo-type1-subset.c
index 0118a79af..fad6144bd 100644
--- a/src/cairo-type1-subset.c
+++ b/src/cairo-type1-subset.c
@@ -167,7 +167,7 @@ _cairo_type1_font_subset_init (cairo_type1_font_subset_t *font,
_cairo_array_init (&font->glyphs_array, sizeof (glyph_data_t));
_cairo_array_init (&font->glyph_names_array, sizeof (char *));
- font->scaled_subset_index_to_glyphs = calloc (scaled_font_subset->num_glyphs, sizeof font->scaled_subset_index_to_glyphs[0]);
+ font->scaled_subset_index_to_glyphs = _cairo_calloc (scaled_font_subset->num_glyphs, sizeof font->scaled_subset_index_to_glyphs[0]);
if (unlikely (font->scaled_subset_index_to_glyphs == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -1355,7 +1355,7 @@ cairo_type1_font_subset_write_private_dict (cairo_type1_font_subset_t *font,
if (font->num_subrs <= 0)
return CAIRO_INT_STATUS_UNSUPPORTED;
- font->subrs = calloc (font->num_subrs, sizeof (font->subrs[0]));
+ font->subrs = _cairo_calloc (font->num_subrs, sizeof (font->subrs[0]));
if (unlikely (font->subrs == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -1410,7 +1410,7 @@ skip_subrs:
font->glyphs = _cairo_array_index (&font->glyphs_array, 0);
font->glyph_names = _cairo_array_index (&font->glyph_names_array, 0);
font->base.num_glyphs = _cairo_array_num_elements (&font->glyphs_array);
- font->type1_subset_index_to_glyphs = calloc (font->base.num_glyphs, sizeof font->type1_subset_index_to_glyphs[0]);
+ font->type1_subset_index_to_glyphs = _cairo_calloc (font->base.num_glyphs, sizeof font->type1_subset_index_to_glyphs[0]);
if (unlikely (font->type1_subset_index_to_glyphs == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -1782,7 +1782,7 @@ _cairo_type1_subset_init (cairo_type1_subset_t *type1_subset,
if (unlikely (type1_subset->base_font == NULL))
goto fail1;
- type1_subset->widths = calloc (scaled_font_subset->num_glyphs, sizeof (double));
+ type1_subset->widths = _cairo_calloc (scaled_font_subset->num_glyphs, sizeof (double));
if (unlikely (type1_subset->widths == NULL))
goto fail2;
diff --git a/src/cairo-xcb-connection.c b/src/cairo-xcb-connection.c
index daa7d4f65..3f1f04508 100644
--- a/src/cairo-xcb-connection.c
+++ b/src/cairo-xcb-connection.c
@@ -686,7 +686,7 @@ _cairo_xcb_connection_get (xcb_connection_t *xcb_connection)
connection->root = xcb_get_setup (xcb_connection);
connection->render = NULL;
- connection->subpixel_orders = calloc (connection->root->roots_len, sizeof(*connection->subpixel_orders));
+ connection->subpixel_orders = _cairo_calloc (connection->root->roots_len, sizeof(*connection->subpixel_orders));
if (unlikely (connection->subpixel_orders == NULL)) {
CAIRO_MUTEX_UNLOCK (connection->device.mutex);
_cairo_xcb_connection_destroy (connection);
diff --git a/src/win32/cairo-win32-printing-surface.c b/src/win32/cairo-win32-printing-surface.c
index a3dd907c2..aa07a80b7 100644
--- a/src/win32/cairo-win32-printing-surface.c
+++ b/src/win32/cairo-win32-printing-surface.c
@@ -1524,7 +1524,7 @@ _cairo_win32_printing_surface_stroke (void *abstract_surface,
dash_array = NULL;
if (style->num_dashes) {
pen_style |= PS_USERSTYLE;
- dash_array = calloc (sizeof (DWORD), style->num_dashes);
+ dash_array = _cairo_calloc (sizeof (DWORD), style->num_dashes);
for (i = 0; i < style->num_dashes; i++) {
dash_array[i] = (DWORD) (scale * style->dash[i]);
}
More information about the cairo-commit
mailing list