diff options
Diffstat (limited to 'src')
47 files changed, 404 insertions, 116 deletions
diff --git a/src/cairo-array.c b/src/cairo-array.c index 3525c78d..58c699e0 100644 --- a/src/cairo-array.c +++ b/src/cairo-array.c @@ -132,8 +132,11 @@ _cairo_array_grow_by (cairo_array_t *array, int additional) if (array->elements == NULL) { array->elements = malloc (sizeof (char *)); - if (array->elements == NULL) + if (array->elements == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } + *array->elements = NULL; } @@ -143,6 +146,7 @@ _cairo_array_grow_by (cairo_array_t *array, int additional) if (new_elements == NULL) { array->size = old_size; + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; } diff --git a/src/cairo-atsui-font.c b/src/cairo-atsui-font.c index 1e174ecc..ab567c6b 100644 --- a/src/cairo-atsui-font.c +++ b/src/cairo-atsui-font.c @@ -811,6 +811,7 @@ _cairo_atsui_font_text_to_glyphs (void *abstract_font, *glyphs = (cairo_glyph_t *) _cairo_malloc_ab(*num_glyphs, sizeof (cairo_glyph_t)); if (*glyphs == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; } diff --git a/src/cairo-base85-stream.c b/src/cairo-base85-stream.c index 08ae8a74..bfde0cfe 100644 --- a/src/cairo-base85-stream.c +++ b/src/cairo-base85-stream.c @@ -114,8 +114,10 @@ _cairo_base85_stream_create (cairo_output_stream_t *output) cairo_base85_stream_t *stream; stream = malloc (sizeof (cairo_base85_stream_t)); - if (stream == NULL) + if (stream == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return (cairo_output_stream_t *) &_cairo_output_stream_nil; + } _cairo_output_stream_init (&stream->base, _cairo_base85_stream_write, diff --git a/src/cairo-bentley-ottmann.c b/src/cairo-bentley-ottmann.c index 267459c9..679b532b 100644 --- a/src/cairo-bentley-ottmann.c +++ b/src/cairo-bentley-ottmann.c @@ -755,8 +755,10 @@ _cairo_bo_event_queue_init (cairo_bo_event_queue_t *event_queue, * event type a union so it doesn't always contain the skip * elt? */ events = _cairo_malloc_ab (num_events, sizeof (cairo_bo_event_t) + sizeof(cairo_bo_event_t*)); - if (events == NULL) + if (events == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } sorted_event_ptrs = (cairo_bo_event_t **) (events + num_events); event_queue->startstop_events = events; @@ -1146,8 +1148,10 @@ _cairo_bo_edge_start_or_continue_trap (cairo_bo_edge_t *edge, if (edge->next) { trap = edge->deferred_trap = _cairo_freelist_alloc (&bo_traps->freelist); - if (!edge->deferred_trap) + if (!edge->deferred_trap) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } trap->right = edge->next; trap->top = top; @@ -1437,8 +1441,10 @@ _cairo_bentley_ottmann_tessellate_polygon (cairo_traps_t *traps, edges = stack_edges; } else { edges = _cairo_malloc_ab (polygon->num_edges, sizeof (cairo_bo_edge_t)); - if (edges == NULL) + if (edges == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } } /* Figure out the bounding box of the input coordinates and diff --git a/src/cairo-cache.c b/src/cairo-cache.c index 18c3d8cc..a7c27c12 100644 --- a/src/cairo-cache.c +++ b/src/cairo-cache.c @@ -131,8 +131,10 @@ _cairo_cache_create (cairo_cache_keys_equal_func_t keys_equal, cairo_cache_t *cache; cache = malloc (sizeof (cairo_cache_t)); - if (cache == NULL) + if (cache == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return NULL; + } status = _cairo_cache_init (cache, keys_equal, entry_destroy, max_size); if (status) { diff --git a/src/cairo-cff-subset.c b/src/cairo-cff-subset.c index 390b1491..aac13780 100644 --- a/src/cairo-cff-subset.c +++ b/src/cairo-cff-subset.c @@ -389,8 +389,11 @@ cff_index_append_copy (cairo_array_t *index, element.length = length; element.is_copy = TRUE; element.data = malloc (element.length); - if (element.data == NULL) - return CAIRO_STATUS_NO_MEMORY; + if (element.data == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); + return CAIRO_STATUS_NO_MEMORY; + } + memcpy (element.data, object, element.length); return _cairo_array_append (index, &element); @@ -440,12 +443,16 @@ cff_dict_create_operator (int operator, cff_dict_operator_t *op; op = malloc (sizeof (cff_dict_operator_t)); - if (op == NULL) + if (op == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return NULL; + } + _cairo_dict_init_key (op, operator); op->operand = malloc (operand_length); if (op->operand == NULL) { free (op); + _cairo_error (CAIRO_STATUS_NO_MEMORY); return NULL; } memcpy (op->operand, operand, operand_length); @@ -544,16 +551,22 @@ cff_dict_set_operands (cairo_hash_table_t *dict, { free (op->operand); op->operand = malloc (size); - if (op->operand == NULL) - return CAIRO_STATUS_NO_MEMORY; + if (op->operand == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); + return CAIRO_STATUS_NO_MEMORY; + } + memcpy (op->operand, operand, size); op->operand_length = size; } else { op = cff_dict_create_operator (operator, operand, size); - if (op == NULL) + if (op == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } + status = _cairo_hash_table_insert (dict, &op->base); if (status) return status; @@ -718,8 +731,10 @@ 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)); - if (font->fdselect == NULL) - return CAIRO_STATUS_NO_MEMORY; + if (font->fdselect == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); + return CAIRO_STATUS_NO_MEMORY; + } type = *p++; if (type == 0) @@ -828,6 +843,7 @@ cairo_cff_font_read_cid_fontdict (cairo_cff_font_t *font, unsigned char *ptr) fail: cff_index_fini (&index); + _cairo_error (status); return status; } @@ -1062,20 +1078,28 @@ cairo_cff_font_subset_fontdict (cairo_cff_font_t *font) font->fdselect_subset = calloc (font->scaled_font_subset->num_glyphs, sizeof (int)); - if (font->fdselect_subset == NULL) + if (font->fdselect_subset == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } font->fd_subset_map = calloc (font->num_fontdicts, sizeof (int)); - if (font->fd_subset_map == NULL) + if (font->fd_subset_map == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } font->private_dict_offset = calloc (font->num_fontdicts, sizeof (int)); - if (font->private_dict_offset == NULL) + if (font->private_dict_offset == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } reverse_map = calloc (font->num_fontdicts, sizeof (int)); - if (reverse_map == NULL) + if (reverse_map == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } for (i = 0; i < font->num_fontdicts; i++) reverse_map[i] = -1; @@ -1103,18 +1127,24 @@ cairo_cff_font_create_cid_fontdict (cairo_cff_font_t *font) font->num_fontdicts = 1; font->fd_dict = malloc (sizeof (cairo_hash_table_t *)); - if (font->fd_dict == NULL) + if (font->fd_dict == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } cff_dict_init (&font->fd_dict[0]); font->fd_subset_map = malloc (sizeof (int)); - if (font->fd_subset_map == NULL) + if (font->fd_subset_map == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } font->private_dict_offset = malloc (sizeof (int)); - if (font->private_dict_offset == NULL) + if (font->private_dict_offset == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } font->fd_subset_map[0] = 0; font->num_subset_fontdicts = 1; @@ -1668,8 +1698,11 @@ _cairo_cff_font_create (cairo_scaled_font_subset_t *scaled_font_subset, return status; name = malloc (size); - if (name == NULL) + if (name == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } + status = backend->load_truetype_table (scaled_font_subset->scaled_font, TT_TAG_name, 0, (unsigned char *) name, &size); @@ -1798,6 +1831,7 @@ fail2: free (font); fail1: free (name); + _cairo_error (status); return status; } @@ -1912,6 +1946,7 @@ _cairo_cff_subset_init (cairo_cff_subset_t *cff_subset, fail1: cairo_cff_font_destroy (font); + _cairo_error (status); return status; } @@ -1932,8 +1967,10 @@ _cairo_cff_font_fallback_create (cairo_scaled_font_subset_t *scaled_font_subset cairo_cff_font_t *font; font = malloc (sizeof (cairo_cff_font_t)); - if (font == NULL) + if (font == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } font->backend = NULL; font->scaled_font_subset = scaled_font_subset; @@ -2000,6 +2037,7 @@ fail2: _cairo_array_fini (&font->output); fail1: free (font); + _cairo_error (status); return status; } diff --git a/src/cairo-clip.c b/src/cairo-clip.c index c1667d27..4f42414b 100644 --- a/src/cairo-clip.c +++ b/src/cairo-clip.c @@ -276,8 +276,10 @@ _cairo_clip_intersect_path (cairo_clip_t *clip, return CAIRO_INT_STATUS_UNSUPPORTED; clip_path = malloc (sizeof (cairo_clip_path_t)); - if (clip_path == NULL) + if (clip_path == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } status = _cairo_path_fixed_init_copy (&clip_path->path, path); if (status) { diff --git a/src/cairo-deflate-stream.c b/src/cairo-deflate-stream.c index 38ce6396..618c6bec 100644 --- a/src/cairo-deflate-stream.c +++ b/src/cairo-deflate-stream.c @@ -118,8 +118,10 @@ _cairo_deflate_stream_create (cairo_output_stream_t *output) cairo_deflate_stream_t *stream; stream = malloc (sizeof (cairo_deflate_stream_t)); - if (stream == NULL) + if (stream == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return (cairo_output_stream_t *) &_cairo_output_stream_nil; + } _cairo_output_stream_init (&stream->base, _cairo_deflate_stream_write, diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c index 409f79d9..50f926cc 100644 --- a/src/cairo-directfb-surface.c +++ b/src/cairo-directfb-surface.c @@ -414,8 +414,10 @@ _cairo_directfb_surface_create_similar (void *abstract_src, format = _cairo_format_from_content (content); surface = calloc (1, sizeof(cairo_directfb_surface_t)); - if (!surface) + if (!surface) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return NULL; + } surface->dfbsurface = _directfb_buffer_surface_create (source->dfb, cairo_to_directfb_format (format), @@ -1119,6 +1121,7 @@ _cairo_directfb_surface_set_clip_region (void *abstract_surface, if (!surface->clips) { _cairo_region_boxes_fini (region, boxes); surface->n_clips = 0; + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; } @@ -1211,12 +1214,15 @@ _directfb_allocate_font_cache (IDirectFB *dfb, int width, int height) cairo_directfb_font_cache_t *cache; cache = calloc (1, sizeof(cairo_directfb_font_cache_t)); - if (!cache) - return NULL; + if (!cache) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); + return NULL; + } cache->dfbsurface = _directfb_buffer_surface_create( dfb, DSPF_A8, width, height); if (!cache->dfbsurface) { free (cache); + _cairo_error (CAIRO_STATUS_NO_MEMORY); return NULL; } @@ -1313,8 +1319,10 @@ _directfb_acquire_font_cache (cairo_directfb_surface_t *surface, /* Remember glyph location */ rect = malloc (sizeof(DFBRectangle)); - if (!rect) + if (!rect) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } *rect = rects[n]; scaled_glyph->surface_private = rect; @@ -1351,8 +1359,10 @@ _directfb_acquire_font_cache (cairo_directfb_surface_t *surface, "Reallocating font cache (%dx%d).\n", w, h); new_cache = _directfb_allocate_font_cache (surface->dfb, w, h); - if (!new_cache) + if (!new_cache) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } new_cache->dfbsurface->Blit (new_cache->dfbsurface, cache->dfbsurface, NULL, 0, 0); @@ -1366,8 +1376,10 @@ _directfb_acquire_font_cache (cairo_directfb_surface_t *surface, "Allocating font cache (%dx%d).\n", w, h); cache = _directfb_allocate_font_cache (surface->dfb, w, h); - if (!cache) - return CAIRO_STATUS_NO_MEMORY; + if (!cache) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); + return CAIRO_STATUS_NO_MEMORY; + } scaled_font->surface_backend = &cairo_directfb_surface_backend; scaled_font->surface_private = cache; @@ -1629,8 +1641,10 @@ cairo_directfb_surface_create (IDirectFB *dfb, IDirectFBSurface *dfbsurface) cairo_directfb_surface_backend_init (dfb); surface = calloc (1, sizeof(cairo_directfb_surface_t)); - if (!surface) - return NULL; + if (!surface) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); + return NULL; + } dfbsurface->GetPixelFormat (dfbsurface, &format); _cairo_surface_init (&surface->base, &cairo_directfb_surface_backend, diff --git a/src/cairo-font-face.c b/src/cairo-font-face.c index c6480209..b3bcc843 100644 --- a/src/cairo-font-face.c +++ b/src/cairo-font-face.c @@ -395,8 +395,10 @@ _cairo_toy_font_face_create (const char *family, /* Otherwise create it and insert into hash table. */ font_face = malloc (sizeof (cairo_toy_font_face_t)); - if (font_face == NULL) + if (font_face == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); goto UNWIND_HASH_TABLE_LOCK; + } status = _cairo_toy_font_face_init (font_face, family, slant, weight); if (status) diff --git a/src/cairo-font-options.c b/src/cairo-font-options.c index 33b021da..b3a5660c 100644 --- a/src/cairo-font-options.c +++ b/src/cairo-font-options.c @@ -86,10 +86,13 @@ _cairo_font_options_init_copy (cairo_font_options_t *options, cairo_font_options_t * cairo_font_options_create (void) { - cairo_font_options_t *options = malloc (sizeof (cairo_font_options_t)); + cairo_font_options_t *options; - if (!options) + options = malloc (sizeof (cairo_font_options_t)); + if (!options) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return (cairo_font_options_t *)&_cairo_font_options_nil; + } _cairo_font_options_init_default (options); @@ -119,8 +122,10 @@ cairo_font_options_copy (const cairo_font_options_t *original) return (cairo_font_options_t *)&_cairo_font_options_nil; options = malloc (sizeof (cairo_font_options_t)); - if (!options) + if (!options) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return (cairo_font_options_t *)&_cairo_font_options_nil; + } _cairo_font_options_init_copy (options, original); diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c index 38a4a8dc..753810a8 100644 --- a/src/cairo-ft-font.c +++ b/src/cairo-ft-font.c @@ -176,8 +176,10 @@ _cairo_ft_unscaled_font_map_create (void) assert (cairo_ft_unscaled_font_map == NULL); font_map = malloc (sizeof (cairo_ft_unscaled_font_map_t)); - if (font_map == NULL) + if (font_map == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); goto FAIL; + } font_map->hash_table = _cairo_hash_table_create (_cairo_ft_unscaled_font_keys_equal); @@ -423,8 +425,10 @@ _cairo_ft_unscaled_font_create_for_pattern (FcPattern *pattern) /* Otherwise create it and insert into hash table. */ unscaled = malloc (sizeof (cairo_ft_unscaled_font_t)); - if (unscaled == NULL) + if (unscaled == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); goto UNWIND_FONT_MAP_LOCK; + } status = _cairo_ft_unscaled_font_init (unscaled, filename, id, NULL); if (status) @@ -456,8 +460,10 @@ _cairo_ft_unscaled_font_create_from_face (FT_Face face) cairo_ft_unscaled_font_t *unscaled; unscaled = malloc (sizeof (cairo_ft_unscaled_font_t)); - if (unscaled == NULL) + if (unscaled == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return NULL; + } status = _cairo_ft_unscaled_font_init (unscaled, NULL, 0, face); if (status) { @@ -1042,7 +1048,6 @@ _render_glyph_outline (FT_Face face, bitmap.width = width * hmul; bitmap.rows = height * vmul; bitmap.buffer = calloc (stride, bitmap.rows); - if (bitmap.buffer == NULL) { _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; diff --git a/src/cairo-glitz-surface.c b/src/cairo-glitz-surface.c index 4b0e74b2..5e68fc7a 100644 --- a/src/cairo-glitz-surface.c +++ b/src/cairo-glitz-surface.c @@ -165,8 +165,10 @@ _cairo_glitz_get_boxes_from_region (cairo_region_t *region, int *nboxes) return NULL; gboxes = _cairo_malloc_ab (n, sizeof(glitz_box_t)); - if (gboxes == NULL) + if (gboxes == NULL) { + _cairo_error (CAIRO_STATUS_SUCCESS); goto done; + } for (i = 0; i < n; i++) { gboxes[i].x1 = cboxes[i].p1.x; @@ -269,12 +271,15 @@ _cairo_glitz_surface_get_image (cairo_glitz_surface_t *surface, pf.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN; pixels = _cairo_malloc_ab (height, pf.bytes_per_line); - if (!pixels) + if (!pixels) { + _cairo_error (CAIRO_STATUS_SUCCESS); return CAIRO_STATUS_NO_MEMORY; + } buffer = glitz_buffer_create_for_data (pixels); if (!buffer) { free (pixels); + _cairo_error (CAIRO_STATUS_SUCCESS); return CAIRO_STATUS_NO_MEMORY; } @@ -775,8 +780,10 @@ _cairo_glitz_pattern_acquire_surface (cairo_pattern_t *pattern, data = malloc (size1 + size2); } - if (!data) + if (!data) { + _cairo_error (CAIRO_STATUS_SUCCESS); return CAIRO_STATUS_NO_MEMORY; + } params = (glitz_fixed16_16_t *) data; pixels = (unsigned int *) @@ -786,6 +793,7 @@ _cairo_glitz_pattern_acquire_surface (cairo_pattern_t *pattern, if (!buffer) { free (data); + _cairo_error (CAIRO_STATUS_SUCCESS); return CAIRO_STATUS_NO_MEMORY; } @@ -1304,6 +1312,7 @@ _cairo_glitz_surface_composite_trapezoids (cairo_operator_t op, &attributes); if (src_pattern == &tmp_src_pattern.base) _cairo_pattern_fini (&tmp_src_pattern.base); + _cairo_error (CAIRO_STATUS_SUCCESS); return CAIRO_STATUS_NO_MEMORY; } @@ -1317,6 +1326,7 @@ _cairo_glitz_surface_composite_trapezoids (cairo_operator_t op, &attributes); if (src_pattern == &tmp_src_pattern.base) _cairo_pattern_fini (&tmp_src_pattern.base); + _cairo_error (CAIRO_STATUS_SUCCESS); return CAIRO_STATUS_NO_MEMORY; } } @@ -1353,6 +1363,7 @@ _cairo_glitz_surface_composite_trapezoids (cairo_operator_t op, _cairo_glitz_pattern_release_surface (src_pattern, src, &attributes); if (src_pattern == &tmp_src_pattern.base) _cairo_pattern_fini (&tmp_src_pattern.base); + _cairo_error (CAIRO_STATUS_SUCCESS); return CAIRO_STATUS_NO_MEMORY; } @@ -1565,8 +1576,10 @@ _cairo_glitz_area_create (cairo_glitz_root_area_t *root, int n = 4; area = malloc (sizeof (cairo_glitz_area_t)); - if (!area) + if (!area) { + _cairo_error (CAIRO_STATUS_SUCCESS); return NULL; + } area->level = level; area->x = x; @@ -1900,8 +1913,10 @@ _cairo_glitz_surface_font_init (cairo_glitz_surface_t *surface, return CAIRO_INT_STATUS_UNSUPPORTED; font_private = malloc (sizeof (cairo_glitz_surface_font_private_t)); - if (!font_private) + if (!font_private) { + _cairo_error (CAIRO_STATUS_SUCCESS); return CAIRO_STATUS_NO_MEMORY; + } font_private->surface = glitz_surface_create (drawable, surface_format, GLYPH_CACHE_TEXTURE_SIZE, @@ -1986,8 +2001,10 @@ _cairo_glitz_surface_add_glyph (cairo_glitz_surface_t *surface, if (glyph_private == NULL) { glyph_private = malloc (sizeof (cairo_glitz_surface_glyph_private_t)); - if (!glyph_private) + if (!glyph_private) { + _cairo_error (CAIRO_STATUS_SUCCESS); return CAIRO_STATUS_NO_MEMORY; + } glyph_private->area = NULL; glyph_private->locked = FALSE; @@ -2151,8 +2168,10 @@ _cairo_glitz_surface_old_show_glyphs (cairo_scaled_font_t *scaled_font, goto FAIL1; data = malloc (size1 + size2); - if (!data) + if (!data) { + _cairo_error (CAIRO_STATUS_SUCCESS); goto FAIL1; + } scaled_glyphs = (cairo_scaled_glyph_t **) data; vertices = (glitz_float_t *) (data + num_glyphs * sizeof (void *)); diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c index 232b040e..32d02e58 100644 --- a/src/cairo-gstate.c +++ b/src/cairo-gstate.c @@ -207,8 +207,10 @@ _cairo_gstate_clone (cairo_gstate_t *other) assert (other != NULL); gstate = malloc (sizeof (cairo_gstate_t)); - if (gstate == NULL) + if (gstate == NULL) { + _cairo_error (CAIRO_STATUS_SUCCESS); return NULL; + } status = _cairo_gstate_init_copy (gstate, other); if (status) { @@ -533,6 +535,7 @@ _cairo_gstate_set_dash (cairo_gstate_t *gstate, const double *dash, int num_dash gstate->stroke_style.dash = _cairo_malloc_ab (gstate->stroke_style.num_dashes, sizeof (double)); if (gstate->stroke_style.dash == NULL) { gstate->stroke_style.num_dashes = 0; + _cairo_error (CAIRO_STATUS_SUCCESS); return CAIRO_STATUS_NO_MEMORY; } @@ -1573,8 +1576,10 @@ _cairo_gstate_show_glyphs (cairo_gstate_t *gstate, transformed_glyphs = stack_transformed_glyphs; } else { transformed_glyphs = _cairo_malloc_ab (num_glyphs, sizeof(cairo_glyph_t)); - if (transformed_glyphs == NULL) + if (transformed_glyphs == NULL) { + _cairo_error (CAIRO_STATUS_SUCCESS); return CAIRO_STATUS_NO_MEMORY; + } } _cairo_gstate_transform_glyphs_to_backend (gstate, glyphs, num_glyphs, @@ -1618,8 +1623,10 @@ _cairo_gstate_glyph_path (cairo_gstate_t *gstate, transformed_glyphs = stack_transformed_glyphs; else transformed_glyphs = _cairo_malloc_ab (num_glyphs, sizeof(cairo_glyph_t)); - if (transformed_glyphs == NULL) + if (transformed_glyphs == NULL) { + _cairo_error (CAIRO_STATUS_SUCCESS); return CAIRO_STATUS_NO_MEMORY; + } _cairo_gstate_transform_glyphs_to_backend (gstate, glyphs, num_glyphs, transformed_glyphs); diff --git a/src/cairo-hash.c b/src/cairo-hash.c index 99343754..09450f70 100644 --- a/src/cairo-hash.c +++ b/src/cairo-hash.c @@ -149,8 +149,10 @@ _cairo_hash_table_create (cairo_hash_keys_equal_func_t keys_equal) cairo_hash_table_t *hash_table; hash_table = malloc (sizeof (cairo_hash_table_t)); - if (hash_table == NULL) + if (hash_table == NULL) { + _cairo_error (CAIRO_STATUS_SUCCESS); return NULL; + } hash_table->keys_equal = keys_equal; @@ -160,6 +162,7 @@ _cairo_hash_table_create (cairo_hash_keys_equal_func_t keys_equal) sizeof(cairo_hash_entry_t *)); if (hash_table->entries == NULL) { free (hash_table); + _cairo_error (CAIRO_STATUS_SUCCESS); return NULL; } @@ -328,8 +331,10 @@ _cairo_hash_table_resize (cairo_hash_table_t *hash_table) new_size = tmp.arrangement->size; tmp.entries = calloc (new_size, sizeof (cairo_hash_entry_t*)); - if (tmp.entries == NULL) + if (tmp.entries == NULL) { + _cairo_error (CAIRO_STATUS_SUCCESS); return CAIRO_STATUS_NO_MEMORY; + } for (i = 0; i < hash_table->arrangement->size; ++i) { if (ENTRY_IS_LIVE (hash_table->entries[i])) { diff --git a/src/cairo-hull.c b/src/cairo-hull.c index c56e9e05..fb4e71c3 100644 --- a/src/cairo-hull.c +++ b/src/cairo-hull.c @@ -63,8 +63,10 @@ _cairo_hull_create (cairo_pen_vertex_t *vertices, int num_vertices) vertices[0].point = tmp; hull = _cairo_malloc_ab (num_vertices, sizeof (cairo_hull_t)); - if (hull == NULL) + if (hull == NULL) { + _cairo_error (CAIRO_STATUS_SUCCESS); return NULL; + } for (i = 0; i < num_vertices; i++) { hull[i].point = vertices[i].point; diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c index 9fbdb59a..1b801734 100644 --- a/src/cairo-image-surface.c +++ b/src/cairo-image-surface.c @@ -1062,8 +1062,10 @@ _cairo_image_surface_fill_rectangles (void *abstract_surface, if (num_rects > ARRAY_LENGTH(stack_rects)) { pixman_rects = _cairo_malloc_ab (num_rects, sizeof(pixman_rectangle16_t)); - if (pixman_rects == NULL) + if (pixman_rects == NULL) { + _cairo_error (CAIRO_STATUS_SUCCESS); return CAIRO_STATUS_NO_MEMORY; + } } for (i = 0; i < num_rects; i++) { @@ -1124,8 +1126,10 @@ _cairo_image_surface_composite_trapezoids (cairo_operator_t op, /* Convert traps to pixman traps */ if (num_traps > ARRAY_LENGTH(stack_traps)) { pixman_traps = _cairo_malloc_ab (num_traps, sizeof(pixman_trapezoid_t)); - if (pixman_traps == NULL) + if (pixman_traps == NULL) { + _cairo_error (CAIRO_STATUS_SUCCESS); return CAIRO_STATUS_NO_MEMORY; + } } for (i = 0; i < num_traps; i++) { @@ -1201,6 +1205,7 @@ _cairo_image_surface_composite_trapezoids (cairo_operator_t op, mask_data = calloc (mask_stride, height); if (mask_data == NULL) { status = CAIRO_STATUS_NO_MEMORY; + _cairo_error (CAIRO_STATUS_SUCCESS); goto CLEANUP_SOURCE; } @@ -1208,6 +1213,7 @@ _cairo_image_surface_composite_trapezoids (cairo_operator_t op, mask_data, mask_stride); if (mask == NULL) { status = CAIRO_STATUS_NO_MEMORY; + _cairo_error (CAIRO_STATUS_SUCCESS); goto CLEANUP_IMAGE_DATA; } diff --git a/src/cairo-lzw.c b/src/cairo-lzw.c index 36a59fda..00aa71b1 100644 --- a/src/cairo-lzw.c +++ b/src/cairo-lzw.c @@ -76,6 +76,7 @@ _lzw_buf_init (lzw_buf_t *buf, int size) if (buf->data == NULL) { buf->data_size = 0; buf->status = CAIRO_STATUS_NO_MEMORY; + _cairo_error (CAIRO_STATUS_SUCCESS); return; } } @@ -102,6 +103,7 @@ _lzw_buf_grow (lzw_buf_t *buf) free (buf->data); buf->data_size = 0; buf->status = CAIRO_STATUS_NO_MEMORY; + _cairo_error (CAIRO_STATUS_SUCCESS); return buf->status; } diff --git a/src/cairo-meta-surface.c b/src/cairo-meta-surface.c index 5fcbf263..3fc61a8f 100644 --- a/src/cairo-meta-surface.c +++ b/src/cairo-meta-surface.c @@ -252,8 +252,10 @@ _cairo_meta_surface_paint (void *abstract_surface, cairo_command_paint_t *command; command = malloc (sizeof (cairo_command_paint_t)); - if (command == NULL) + if (command == NULL) { + _cairo_error (CAIRO_STATUS_SUCCESS); return CAIRO_STATUS_NO_MEMORY; + } command->header.type = CAIRO_COMMAND_PAINT; command->header.region = CAIRO_META_REGION_ALL; @@ -293,8 +295,10 @@ _cairo_meta_surface_mask (void *abstract_surface, cairo_command_mask_t *command; command = malloc (sizeof (cairo_command_mask_t)); - if (command == NULL) + if (command == NULL) { + _cairo_error (CAIRO_STATUS_SUCCESS); return CAIRO_STATUS_NO_MEMORY; + } command->header.type = CAIRO_COMMAND_MASK; command->header.region = CAIRO_META_REGION_ALL; @@ -339,8 +343,10 @@ _cairo_meta_surface_stroke (void *abstract_surface, cairo_command_stroke_t *command; command = malloc (sizeof (cairo_command_stroke_t)); - if (command == NULL) + if (command == NULL) { + _cairo_error (CAIRO_STATUS_SUCCESS); return CAIRO_STATUS_NO_MEMORY; + } command->header.type = CAIRO_COMMAND_STROKE; command->header.region = CAIRO_META_REGION_ALL; @@ -394,8 +400,10 @@ _cairo_meta_surface_fill (void *abstract_surface, cairo_command_fill_t *command; command = malloc (sizeof (cairo_command_fill_t)); - if (command == NULL) + if (command == NULL) { + _cairo_error (CAIRO_STATUS_SUCCESS); return CAIRO_STATUS_NO_MEMORY; + } command->header.type = CAIRO_COMMAND_FILL; command->header.region = CAIRO_META_REGION_ALL; @@ -441,8 +449,10 @@ _cairo_meta_surface_show_glyphs (void *abstract_surface, cairo_command_show_glyphs_t *command; command = malloc (sizeof (cairo_command_show_glyphs_t)); - if (command == NULL) + if (command == NULL) { + _cairo_error (CAIRO_STATUS_SUCCESS); return CAIRO_STATUS_NO_MEMORY; + } command->header.type = CAIRO_COMMAND_SHOW_GLYPHS; command->header.region = CAIRO_META_REGION_ALL; @@ -476,6 +486,7 @@ _cairo_meta_surface_show_glyphs (void *abstract_surface, _cairo_pattern_fini (&command->source.base); CLEANUP_COMMAND: free (command); + _cairo_error (status); return status; } @@ -531,8 +542,10 @@ _cairo_meta_surface_intersect_clip_path (void *dst, cairo_status_t status; command = malloc (sizeof (cairo_command_intersect_clip_path_t)); - if (command == NULL) + if (command == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } command->header.type = CAIRO_COMMAND_INTERSECT_CLIP_PATH; command->header.region = CAIRO_META_REGION_ALL; @@ -799,6 +812,7 @@ _cairo_meta_surface_replay_internal (cairo_surface_t *surface, dev_glyphs = _cairo_malloc_ab (num_glyphs, sizeof (cairo_glyph_t)); if (dev_glyphs == NULL) { status = CAIRO_STATUS_NO_MEMORY; + _cairo_error (CAIRO_STATUS_NO_MEMORY); break; } for (i = 0; i < num_glyphs; i++) { diff --git a/src/cairo-output-stream.c b/src/cairo-output-stream.c index b9f0d383..a0add6d7 100644 --- a/src/cairo-output-stream.c +++ b/src/cairo-output-stream.c @@ -119,8 +119,10 @@ _cairo_output_stream_create (cairo_write_func_t write_func, cairo_output_stream_with_closure_t *stream; stream = malloc (sizeof (cairo_output_stream_with_closure_t)); - if (stream == NULL) + if (stream == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return (cairo_output_stream_t *) &_cairo_output_stream_nil; + } _cairo_output_stream_init (&stream->base, closure_write, closure_close); stream->write_func = write_func; @@ -468,12 +470,16 @@ _cairo_output_stream_create_for_file (FILE *file) { stdio_stream_t *stream; - if (file == NULL) + if (file == NULL) { + _cairo_error (CAIRO_STATUS_WRITE_ERROR); return (cairo_output_stream_t *) &_cairo_output_stream_nil_write_error; + } stream = malloc (sizeof *stream); - if (stream == NULL) + if (stream == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return (cairo_output_stream_t *) &_cairo_output_stream_nil; + } _cairo_output_stream_init (&stream->base, stdio_write, stdio_flush); stream->file = file; @@ -488,12 +494,15 @@ _cairo_output_stream_create_for_filename (const char *filename) FILE *file; file = fopen (filename, "wb"); - if (file == NULL) + if (file == NULL) { + _cairo_error (CAIRO_STATUS_WRITE_ERROR); return (cairo_output_stream_t *) &_cairo_output_stream_nil_write_error; + } stream = malloc (sizeof *stream); if (stream == NULL) { fclose (file); + _cairo_error (CAIRO_STATUS_NO_MEMORY); return (cairo_output_stream_t *) &_cairo_output_stream_nil; } @@ -534,8 +543,10 @@ _cairo_memory_stream_create (void) memory_stream_t *stream; stream = malloc (sizeof *stream); - if (stream == NULL) + if (stream == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return (cairo_output_stream_t *) &_cairo_output_stream_nil; + } _cairo_output_stream_init (&stream->base, memory_write, memory_close); _cairo_array_init (&stream->array, 1); diff --git a/src/cairo-paginated-surface.c b/src/cairo-paginated-surface.c index 007cc89e..76eb6616 100644 --- a/src/cairo-paginated-surface.c +++ b/src/cairo-paginated-surface.c @@ -76,8 +76,10 @@ _cairo_paginated_surface_create (cairo_surface_t *target, cairo_paginated_surface_t *surface; surface = malloc (sizeof (cairo_paginated_surface_t)); - if (surface == NULL) + if (surface == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); goto FAIL; + } _cairo_surface_init (&surface->base, &cairo_paginated_surface_backend, content); diff --git a/src/cairo-path-fixed.c b/src/cairo-path-fixed.c index 7c8f34bd..56b1df2d 100644 --- a/src/cairo-path-fixed.c +++ b/src/cairo-path-fixed.c @@ -120,10 +120,14 @@ _cairo_path_fixed_init_copy (cairo_path_fixed_t *path, cairo_path_fixed_t * _cairo_path_fixed_create (void) { - cairo_path_fixed_t *path = malloc (sizeof (cairo_path_fixed_t)); + cairo_path_fixed_t *path; - if (!path) + path = malloc (sizeof (cairo_path_fixed_t)); + if (!path) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return NULL; + } + _cairo_path_fixed_init (path); return path; } diff --git a/src/cairo-path-stroke.c b/src/cairo-path-stroke.c index 70001977..0a295baf 100644 --- a/src/cairo-path-stroke.c +++ b/src/cairo-path-stroke.c @@ -1066,8 +1066,11 @@ _cairo_rectilinear_stroker_add_segment (cairo_rectilinear_stroker_t *stroker, new_size = 4; new_segments = _cairo_realloc_ab (stroker->segments, new_size, sizeof (cairo_line_t)); - if (new_segments == NULL) + if (new_segments == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } + stroker->segments_size = new_size; stroker->segments = new_segments; } diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c index 1830634e..eac7e4bf 100644 --- a/src/cairo-pattern.c +++ b/src/cairo-pattern.c @@ -771,6 +771,7 @@ _cairo_pattern_gradient_grow (cairo_gradient_pattern_t *pattern) } if (new_stops == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; } @@ -1160,8 +1161,10 @@ _cairo_pattern_acquire_surface_for_gradient (cairo_gradient_pattern_t *pattern, if (pattern->n_stops > ARRAY_LENGTH(pixman_stops_static)) { pixman_stops = _cairo_malloc_ab (pattern->n_stops, sizeof(pixman_gradient_stop_t)); - if (pixman_stops == NULL) + if (pixman_stops == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } } for (i = 0; i < pattern->n_stops; i++) { diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c index fe4dd826..043d8f4c 100644 --- a/src/cairo-pdf-surface.c +++ b/src/cairo-pdf-surface.c @@ -1181,8 +1181,10 @@ compress_dup (const void *data, unsigned long data_size, /* Bound calculation taken from zlib. */ *compressed_size = data_size + (data_size >> 12) + (data_size >> 14) + 11; compressed = malloc (*compressed_size); - if (compressed == NULL) + if (compressed == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return NULL; + } if (compress (compressed, compressed_size, data, data_size) != Z_OK) { free (compressed); @@ -1220,6 +1222,7 @@ _cairo_pdf_surface_emit_smask (cairo_pdf_surface_t *surface, alpha = malloc (alpha_size); if (alpha == NULL) { status = CAIRO_STATUS_NO_MEMORY; + _cairo_error (CAIRO_STATUS_NO_MEMORY); goto CLEANUP; } @@ -1313,6 +1316,7 @@ _cairo_pdf_surface_emit_image (cairo_pdf_surface_t *surface, rgb = malloc (rgb_size); if (rgb == NULL) { status = CAIRO_STATUS_NO_MEMORY; + _cairo_error (CAIRO_STATUS_NO_MEMORY); goto CLEANUP; } @@ -1884,8 +1888,10 @@ _cairo_pdf_surface_emit_pattern_stops (cairo_pdf_surface_t *surface, alpha_function->id = 0; allstops = _cairo_malloc_ab ((pattern->n_stops + 2), sizeof (cairo_pdf_color_stop_t)); - if (allstops == NULL) + if (allstops == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } stops = &allstops[1]; n_stops = pattern->n_stops; diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c index 27bf849b..77d3820b 100644 --- a/src/cairo-ps-surface.c +++ b/src/cairo-ps-surface.c @@ -149,8 +149,10 @@ _word_wrap_stream_create (cairo_output_stream_t *output, int max_column) word_wrap_stream_t *stream; stream = malloc (sizeof (word_wrap_stream_t)); - if (stream == NULL) + if (stream == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return (cairo_output_stream_t *) &_cairo_output_stream_nil; + } _cairo_output_stream_init (&stream->base, _word_wrap_stream_write, @@ -1565,8 +1567,10 @@ _string_array_stream_create (cairo_output_stream_t *output) string_array_stream_t *stream; stream = malloc (sizeof (string_array_stream_t)); - if (stream == NULL) + if (stream == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return (cairo_output_stream_t *) &_cairo_output_stream_nil; + } _cairo_output_stream_init (&stream->base, _string_array_stream_write, @@ -1647,6 +1651,7 @@ _cairo_ps_surface_emit_image (cairo_ps_surface_t *surface, rgb = malloc (rgb_size); if (rgb == NULL) { status = CAIRO_STATUS_NO_MEMORY; + _cairo_error (CAIRO_STATUS_NO_MEMORY); goto bail1; } @@ -2117,8 +2122,10 @@ _cairo_ps_surface_stroke (void *abstract_surface, */ if (num_dashes % 2) { dash = _cairo_malloc_abc (num_dashes, 2, sizeof (double)); - if (dash == NULL) + if (dash == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } memcpy (dash, style->dash, num_dashes * sizeof (double)); memcpy (dash + num_dashes, style->dash, num_dashes * sizeof (double)); @@ -2299,8 +2306,10 @@ _cairo_ps_surface_show_glyphs (void *abstract_surface, _cairo_ps_surface_emit_pattern (surface, source); glyph_ids = _cairo_malloc_ab (num_glyphs_unsigned, sizeof (cairo_ps_glyph_id_t)); - if (glyph_ids == NULL) - return CAIRO_STATUS_NO_MEMORY; + if (glyph_ids == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); + return CAIRO_STATUS_NO_MEMORY; + } for (i = 0; i < num_glyphs_unsigned; i++) { status = _cairo_scaled_font_subsets_map_glyph (surface->font_subsets, diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c index 540bdca7..8a90f309 100644 --- a/src/cairo-quartz-surface.c +++ b/src/cairo-quartz-surface.c @@ -1256,6 +1256,10 @@ _cairo_quartz_surface_stroke (void *abstract_surface, unsigned int k; if (style->num_dashes > STATIC_DASH) fdash = _cairo_malloc_ab (style->num_dashes, sizeof (float)); + if (fdash == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); + return CAIRO_STATUS_NO_MEMORY; + } for (k = 0; k < style->num_dashes; k++) fdash[k] = (float) style->dash[k]; @@ -1395,7 +1399,17 @@ _cairo_quartz_surface_show_glyphs (void *abstract_surface, if (num_glyphs > STATIC_BUF_SIZE) { cg_glyphs = (CGGlyph*) _cairo_malloc_ab (num_glyphs, sizeof(CGGlyph)); + if (cg_glyphs == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); + return CAIRO_STATUS_NO_MEMORY; + } + cg_advances = (CGSize*) _cairo_malloc_ab (num_glyphs, sizeof(CGSize)); + if (cg_glyphs == NULL) { + free (cg_advances); + _cairo_error (CAIRO_STATUS_NO_MEMORY); + return CAIRO_STATUS_NO_MEMORY; + } } xprev = glyphs[0].x; diff --git a/src/cairo-region.c b/src/cairo-region.c index e5889c72..ea4ccc37 100644 --- a/src/cairo-region.c +++ b/src/cairo-region.c @@ -66,8 +66,10 @@ _cairo_region_init_boxes (cairo_region_t *region, if (count > ARRAY_LENGTH(stack_pboxes)) { pboxes = _cairo_malloc_ab (count, sizeof(pixman_box16_t)); - if (pboxes == NULL) + if (pboxes == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } } for (i = 0; i < count; i++) { diff --git a/src/cairo-scaled-font-subsets.c b/src/cairo-scaled-font-subsets.c index ea2e63ae..a5d9c49e 100644 --- a/src/cairo-scaled-font-subsets.c +++ b/src/cairo-scaled-font-subsets.c @@ -124,8 +124,10 @@ _cairo_sub_font_glyph_create (unsigned long scaled_font_glyph_index, cairo_sub_font_glyph_t *sub_font_glyph; sub_font_glyph = malloc (sizeof (cairo_sub_font_glyph_t)); - if (sub_font_glyph == NULL) + if (sub_font_glyph == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return NULL; + } _cairo_sub_font_glyph_init_key (sub_font_glyph, scaled_font_glyph_index); sub_font_glyph->subset_id = subset_id; @@ -214,8 +216,10 @@ _cairo_sub_font_create (cairo_scaled_font_subsets_t *parent, cairo_sub_font_t *sub_font; sub_font = malloc (sizeof (cairo_sub_font_t)); - if (sub_font == NULL) + if (sub_font == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return NULL; + } sub_font->is_scaled = is_scaled; sub_font->is_composite = is_composite; @@ -410,9 +414,11 @@ _cairo_scaled_font_subsets_create_internal (cairo_subsets_type_t type) { cairo_scaled_font_subsets_t *subsets; - subsets = malloc (sizeof (cairo_scaled_font_subsets_t)); - if (subsets == NULL) + subsets = malloc (sizeof (cairo_scaled_font_subsets_t)); + if (subsets == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return NULL; + } subsets->type = type; subsets->max_glyphs_per_unscaled_subset_used = 0; @@ -623,8 +629,10 @@ _cairo_scaled_font_subsets_foreach_internal (cairo_scaled_font_subsets_t return CAIRO_STATUS_SUCCESS; collection.glyphs = _cairo_malloc_ab (collection.glyphs_size, sizeof(unsigned long)); - if (collection.glyphs == NULL) + if (collection.glyphs == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } collection.font_subset_callback = font_subset_callback; collection.font_subset_callback_closure = closure; diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c index f3808c92..282a4868 100644 --- a/src/cairo-scaled-font.c +++ b/src/cairo-scaled-font.c @@ -324,6 +324,7 @@ _cairo_scaled_font_map_lock (void) cairo_scaled_font_map = NULL; CLEANUP_MUTEX_LOCK: CAIRO_MUTEX_UNLOCK (_cairo_scaled_font_map_mutex); + _cairo_error (CAIRO_STATUS_NO_MEMORY); return NULL; } @@ -1036,6 +1037,7 @@ _cairo_scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font, if (*glyphs == NULL) { status = CAIRO_STATUS_NO_MEMORY; + _cairo_error (CAIRO_STATUS_NO_MEMORY); goto DONE; } @@ -1626,6 +1628,7 @@ _cairo_scaled_glyph_lookup (cairo_scaled_font_t *scaled_font, scaled_glyph = malloc (sizeof (cairo_scaled_glyph_t)); if (scaled_glyph == NULL) { status = CAIRO_STATUS_NO_MEMORY; + _cairo_error (CAIRO_STATUS_NO_MEMORY); goto CLEANUP; } diff --git a/src/cairo-skiplist.c b/src/cairo-skiplist.c index 72ca6ce1..fe80263f 100644 --- a/src/cairo-skiplist.c +++ b/src/cairo-skiplist.c @@ -355,8 +355,11 @@ _cairo_skip_list_insert (cairo_skip_list_t *list, void *data, int unique) } data_and_elt = alloc_node_for_level (list, level); - if (data_and_elt == NULL) + if (data_and_elt == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return NULL; + } + memcpy (data_and_elt, data, list->data_size); elt = (skip_elt_t *) (data_and_elt + list->data_size); diff --git a/src/cairo-spline.c b/src/cairo-spline.c index 70c4ede6..f22f6464 100644 --- a/src/cairo-spline.c +++ b/src/cairo-spline.c @@ -118,6 +118,7 @@ _cairo_spline_grow (cairo_spline_t *spline) } if (new_points == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; } diff --git a/src/cairo-stroke-style.c b/src/cairo-stroke-style.c index 2eccb80d..ea6b4128 100644 --- a/src/cairo-stroke-style.c +++ b/src/cairo-stroke-style.c @@ -63,8 +63,10 @@ _cairo_stroke_style_init_copy (cairo_stroke_style_t *style, style->dash = NULL; } else { style->dash = _cairo_malloc_ab (style->num_dashes, sizeof (double)); - if (style->dash == NULL) + if (style->dash == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } memcpy (style->dash, other->dash, style->num_dashes * sizeof (double)); diff --git a/src/cairo-surface-fallback.c b/src/cairo-surface-fallback.c index ab19d2c2..37aee51f 100644 --- a/src/cairo-surface-fallback.c +++ b/src/cairo-surface-fallback.c @@ -1172,6 +1172,7 @@ _cairo_surface_fallback_fill_rectangles (cairo_surface_t *surface, offset_rects = _cairo_malloc_ab (num_rects, sizeof (cairo_rectangle_int_t)); if (offset_rects == NULL) { status = CAIRO_STATUS_NO_MEMORY; + _cairo_error (CAIRO_STATUS_NO_MEMORY); goto DONE; } @@ -1228,6 +1229,7 @@ _cairo_surface_fallback_composite_trapezoids (cairo_operator_t op, offset_traps = _cairo_malloc_ab (num_traps, sizeof (cairo_trapezoid_t)); if (!offset_traps) { status = CAIRO_STATUS_NO_MEMORY; + _cairo_error (CAIRO_STATUS_NO_MEMORY); goto DONE; } diff --git a/src/cairo-surface.c b/src/cairo-surface.c index 05dc9067..b5fcc648 100644 --- a/src/cairo-surface.c +++ b/src/cairo-surface.c @@ -1268,6 +1268,7 @@ _cairo_surface_fill_region (cairo_surface_t *surface, rects = _cairo_malloc_ab (num_boxes, sizeof (cairo_rectangle_int_t)); if (!rects) { _cairo_region_boxes_fini (region, boxes); + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; } } diff --git a/src/cairo-traps.c b/src/cairo-traps.c index 8abd4ddc..32743b4f 100644 --- a/src/cairo-traps.c +++ b/src/cairo-traps.c @@ -270,6 +270,7 @@ _cairo_traps_grow (cairo_traps_t *traps) } if (new_traps == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); traps->status = CAIRO_STATUS_NO_MEMORY; return traps->status; } @@ -614,8 +615,10 @@ _cairo_traps_extract_region (cairo_traps_t *traps, if (traps->num_traps > ARRAY_LENGTH(stack_boxes)) { boxes = _cairo_malloc_ab (traps->num_traps, sizeof(cairo_box_int_t)); - if (boxes == NULL) + if (boxes == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } } box_count = 0; diff --git a/src/cairo-truetype-subset.c b/src/cairo-truetype-subset.c index 83f35fda..5afab3a3 100644 --- a/src/cairo-truetype-subset.c +++ b/src/cairo-truetype-subset.c @@ -270,6 +270,7 @@ _cairo_truetype_font_create (cairo_scaled_font_subset_t *scaled_font_subset, if (name) free (name); + _cairo_error (status); return status; } @@ -511,6 +512,7 @@ cairo_truetype_font_write_glyf_table (cairo_truetype_font_t *font, u.bytes = malloc (size); if (u.bytes == NULL) { font->status = CAIRO_STATUS_NO_MEMORY; + _cairo_error (CAIRO_STATUS_NO_MEMORY); return font->status; } @@ -1038,6 +1040,7 @@ _cairo_truetype_subset_init (cairo_truetype_subset_t *truetype_subset, fail1: cairo_truetype_font_destroy (font); + _cairo_error (status); return status; } @@ -1083,8 +1086,11 @@ _cairo_truetype_map_glyphs_to_unicode (cairo_scaled_font_subset_t *font_subset, size = be16_to_cpu (map->length); map = malloc (size); - if (map == NULL) + if (map == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } + if (backend->load_truetype_table (font_subset->scaled_font, TT_TAG_cmap, table_offset, (unsigned char *) map, @@ -1167,8 +1173,11 @@ _cairo_truetype_create_glyph_to_unicode_map (cairo_scaled_font_subset_t *font_su num_tables = be16_to_cpu (cmap->num_tables); size = 4 + num_tables*sizeof(tt_cmap_index_t); cmap = malloc (size); - if (cmap == NULL) + if (cmap == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } + if (backend->load_truetype_table (font_subset->scaled_font, TT_TAG_cmap, 0, (unsigned char *) cmap, &size) != CAIRO_STATUS_SUCCESS) { diff --git a/src/cairo-type1-fallback.c b/src/cairo-type1-fallback.c index 38727778..564b4b06 100644 --- a/src/cairo-type1-fallback.c +++ b/src/cairo-type1-fallback.c @@ -80,13 +80,16 @@ cairo_type1_font_create (cairo_scaled_font_subset_t *scaled_font_subset, cairo_font_options_t font_options; font = calloc (1, sizeof (cairo_type1_font_t)); - if (font == NULL) + if (font == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } font->widths = calloc (scaled_font_subset->num_glyphs, sizeof (int)); if (font->widths == NULL) { free (font); + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; } @@ -781,6 +784,7 @@ _cairo_type1_fallback_init_internal (cairo_type1_subset_t *type1_subset, /* status is already set, ignore further errors */ cairo_type1_font_destroy (font); + _cairo_error (status); return status; } @@ -873,6 +877,7 @@ fail2: _cairo_type2_charstrings_fini (type2_subset); fail1: cairo_type1_font_destroy (font); + _cairo_error (status); return status; } diff --git a/src/cairo-type1-subset.c b/src/cairo-type1-subset.c index 0716005b..793faf35 100644 --- a/src/cairo-type1-subset.c +++ b/src/cairo-type1-subset.c @@ -119,6 +119,8 @@ _cairo_type1_font_subset_create (cairo_unscaled_font_t *unscaled_font, ft_unscaled_font = (cairo_ft_unscaled_font_t *) unscaled_font; face = _cairo_ft_unscaled_font_lock_face (ft_unscaled_font); + if (!face) + return CAIRO_STATUS_NO_MEMORY; if (FT_Get_PS_Font_Info(face, &font_info) != 0) { status = CAIRO_INT_STATUS_UNSUPPORTED; @@ -179,6 +181,8 @@ _cairo_type1_font_subset_create (cairo_unscaled_font_t *unscaled_font, fail1: _cairo_ft_unscaled_font_unlock_face (ft_unscaled_font); + if (status != CAIRO_INT_STATUS_UNSUPPORTED) + _cairo_error (status); return status; } @@ -368,10 +372,12 @@ cairo_type1_font_subset_decrypt_eexec_segment (cairo_type1_font_subset_t *font) end = (unsigned char *) in + font->eexec_segment_size; font->cleartext = malloc (font->eexec_segment_size); - if (font->cleartext == NULL) + if (font->cleartext == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return font->status = CAIRO_STATUS_NO_MEMORY; - out = font->cleartext; + } + out = font->cleartext; while (in < end) { if (font->eexec_segment_is_ascii) { c = *in++; @@ -386,7 +392,6 @@ cairo_type1_font_subset_decrypt_eexec_segment (cairo_type1_font_subset_t *font) *out++ = p; } - font->cleartext_end = out; return font->status; @@ -714,8 +719,10 @@ cairo_type1_font_subset_look_for_seac(cairo_type1_font_subset_t *font, int command; charstring = malloc (encrypted_charstring_length); - if (charstring == NULL) + if (charstring == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return; + } cairo_type1_font_subset_decrypt_charstring ((const unsigned char *) encrypted_charstring, @@ -1041,15 +1048,20 @@ cairo_type1_font_subset_generate (void *abstract_font, unsigned long ret; ft_unscaled_font = (cairo_ft_unscaled_font_t *) font->base.unscaled_font; - font->face = _cairo_ft_unscaled_font_lock_face (ft_unscaled_font); /* If anything fails below, it's out of memory. */ font->status = CAIRO_STATUS_NO_MEMORY; + font->face = _cairo_ft_unscaled_font_lock_face (ft_unscaled_font); + if (!font->face) + return CAIRO_STATUS_NO_MEMORY; + font->type1_length = font->face->stream->size; font->type1_data = malloc (font->type1_length); - if (font->type1_data == NULL) + if (font->type1_data == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); goto fail; + } if (font->face->stream->read) { ret = font->face->stream->read (font->face->stream, 0, @@ -1184,6 +1196,8 @@ _cairo_type1_subset_init (cairo_type1_subset_t *type1_subset, fail1: cairo_type1_font_subset_destroy (font); + if (status != CAIRO_INT_STATUS_UNSUPPORTED) + _cairo_error (status); return status; } diff --git a/src/cairo-unicode.c b/src/cairo-unicode.c index 1d1c00a9..8ee6d246 100644 --- a/src/cairo-unicode.c +++ b/src/cairo-unicode.c @@ -241,8 +241,10 @@ _cairo_utf8_to_ucs4 (const unsigned char *str, } str32 = _cairo_malloc_ab (n_chars + 1, sizeof (uint32_t)); - if (!str32) + if (!str32) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } in = str; for (i=0; i < n_chars; i++) { @@ -308,8 +310,10 @@ _cairo_utf8_to_utf16 (const unsigned char *str, } str16 = _cairo_malloc_ab (n16 + 1, sizeof (uint16_t)); - if (!str16) + if (!str16) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } in = str; for (i = 0; i < n16;) { diff --git a/src/cairo-win32-font.c b/src/cairo-win32-font.c index 81213e77..a883490e 100644 --- a/src/cairo-win32-font.c +++ b/src/cairo-win32-font.c @@ -246,8 +246,10 @@ _win32_scaled_font_create (LOGFONTW *logfont, cairo_status_t status; f = malloc (sizeof(cairo_win32_scaled_font_t)); - if (f == NULL) + if (f == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return NULL; + } f->logfont = *logfont; @@ -412,8 +414,10 @@ _win32_scaled_font_get_unscaled_hfont (cairo_win32_scaled_font_t *scaled_font, } otm = malloc (otm_size); - if (!otm) + if (!otm) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return NULL; + } if (!GetOutlineTextMetrics (hdc, otm_size, otm)) { _cairo_win32_print_gdi_error ("_win32_scaled_font_get_unscaled_hfont:GetOutlineTextMetrics"); @@ -691,6 +695,7 @@ _cairo_win32_scaled_font_text_to_glyphs (void *abstract_font, FAIL1: free (utf16); + _cairo_error (status); return status; } diff --git a/src/cairo-win32-surface.c b/src/cairo-win32-surface.c index 1b1a2ff8..4b27a8db 100644 --- a/src/cairo-win32-surface.c +++ b/src/cairo-win32-surface.c @@ -187,8 +187,10 @@ _create_dc_and_bitmap (cairo_win32_surface_t *surface, if (num_palette > 2) { bitmap_info = _cairo_malloc_ab_plus_c (num_palette, sizeof(RGBQUAD), sizeof(BITMAPINFOHEADER)); - if (!bitmap_info) + if (!bitmap_info) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } } else { bitmap_info = (BITMAPINFO *)&bmi_stack; } @@ -1467,6 +1469,7 @@ _cairo_win32_surface_set_clip_region (void *abstract_surface, data = malloc (data_size); if (!data) { _cairo_region_boxes_fini (region, boxes); + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; } rects = (RECT *)data->Buffer; diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c index bcdadae4..d5c27d65 100644 --- a/src/cairo-xcb-surface.c +++ b/src/cairo-xcb-surface.c @@ -406,6 +406,7 @@ _get_image_surface (cairo_xcb_surface_t *surface, data = _cairo_malloc_ab (surface->height, bytes_per_line); if (data == NULL) { free (imagerep); + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; } @@ -1265,8 +1266,10 @@ _cairo_xcb_surface_fill_rectangles (void *abstract_surface, if (num_rects > ARRAY_LENGTH(static_xrects)) { xrects = _cairo_malloc_ab (num_rects, sizeof(xcb_rectangle_t)); - if (xrects == NULL) - return CAIRO_STATUS_NO_MEMORY; + if (xrects == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); + return CAIRO_STATUS_NO_MEMORY; + } } for (i = 0; i < num_rects; i++) { @@ -1347,8 +1350,10 @@ _create_trapezoid_mask (cairo_xcb_surface_t *dst, solid_picture = _create_a8_picture (dst, &solid, width, height, TRUE); offset_traps = _cairo_malloc_ab (num_traps, sizeof (xcb_render_trapezoid_t)); - if (!offset_traps) + if (!offset_traps) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return XCB_NONE; + } for (i = 0; i < num_traps; i++) { offset_traps[i].top = _cairo_fixed_to_16_16(traps[i].top) - 0x10000 * dst_y; @@ -1496,6 +1501,7 @@ _cairo_xcb_surface_composite_trapezoids (cairo_operator_t op, xtraps = _cairo_malloc_ab (num_traps, sizeof(xcb_render_trapezoid_t)); if (xtraps == NULL) { status = CAIRO_STATUS_NO_MEMORY; + _cairo_error (CAIRO_STATUS_NO_MEMORY); goto BAIL; } } @@ -1565,6 +1571,7 @@ _cairo_xcb_surface_set_clip_region (void *abstract_surface, rects = _cairo_malloc_ab (n_boxes, sizeof(xcb_rectangle_t)); if (rects == NULL) { _cairo_region_boxes_fini (region, boxes); + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; } } else { @@ -1989,8 +1996,10 @@ _cairo_xcb_surface_font_init (xcb_connection_t *dpy, cairo_xcb_surface_font_private_t *font_private; font_private = malloc (sizeof (cairo_xcb_surface_font_private_t)); - if (!font_private) + if (!font_private) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } font_private->dpy = dpy; font_private->format = format; @@ -2109,6 +2118,7 @@ _cairo_xcb_surface_add_glyph (xcb_connection_t *dpy, new = malloc (c); if (!new) { status = CAIRO_STATUS_NO_MEMORY; + _cairo_error (CAIRO_STATUS_NO_MEMORY); goto BAIL; } n = new; @@ -2135,6 +2145,7 @@ _cairo_xcb_surface_add_glyph (xcb_connection_t *dpy, new = malloc (c); if (new == NULL) { status = CAIRO_STATUS_NO_MEMORY; + _cairo_error (CAIRO_STATUS_NO_MEMORY); goto BAIL; } n = new; @@ -2374,8 +2385,10 @@ _cairo_xcb_surface_show_glyphs (void *abstract_dst, * glyphs to workaround an X server bug, (present in at least Xorg * 7.1 without EXA). */ output_glyphs = _cairo_malloc_ab (num_glyphs, sizeof (cairo_glyph_t)); - if (output_glyphs == NULL) + if (output_glyphs == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } /* After passing all those tests, we're now committed to rendering * these glyphs or to fail trying. We first upload any glyphs to diff --git a/src/cairo-xlib-display.c b/src/cairo-xlib-display.c index 673c5467..6e8f2ba5 100644 --- a/src/cairo-xlib-display.c +++ b/src/cairo-xlib-display.c @@ -251,8 +251,10 @@ _cairo_xlib_display_get (Display *dpy) } display = malloc (sizeof (cairo_xlib_display_t)); - if (display == NULL) + if (display == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); goto UNLOCK; + } /* Xlib calls out to the extension close_display hooks in LIFO * order. So we have to ensure that all extensions that we depend diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c index 9478594f..65e2d6a8 100644 --- a/src/cairo-xlib-surface.c +++ b/src/cairo-xlib-surface.c @@ -1445,8 +1445,10 @@ _cairo_xlib_surface_fill_rectangles (void *abstract_surface, if (num_rects > ARRAY_LENGTH(static_xrects)) { xrects = _cairo_malloc_ab (num_rects, sizeof(XRectangle)); - if (xrects == NULL) - return CAIRO_STATUS_NO_MEMORY; + if (xrects == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); + return CAIRO_STATUS_NO_MEMORY; + } } for (i = 0; i < num_rects; i++) { @@ -1534,6 +1536,7 @@ _create_trapezoid_mask (cairo_xlib_surface_t *dst, offset_traps = _cairo_malloc_ab (num_traps, sizeof (XTrapezoid)); if (!offset_traps) { XRenderFreePicture (dst->dpy, mask_picture); + _cairo_error (CAIRO_STATUS_NO_MEMORY); return None; } @@ -1684,6 +1687,7 @@ _cairo_xlib_surface_composite_trapezoids (cairo_operator_t op, xtraps = _cairo_malloc_ab (num_traps, sizeof(XTrapezoid)); if (xtraps == NULL) { status = CAIRO_STATUS_NO_MEMORY; + _cairo_error (CAIRO_STATUS_NO_MEMORY); goto BAIL; } } @@ -1748,6 +1752,7 @@ _cairo_xlib_surface_set_clip_region (void *abstract_surface, rects = _cairo_malloc_ab (n_boxes, sizeof(XRectangle)); if (rects == NULL) { _cairo_region_boxes_fini (region, boxes); + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; } } else { @@ -2451,13 +2456,16 @@ _cairo_xlib_surface_font_init (Display *dpy, cairo_xlib_surface_font_private_t *font_private; font_private = malloc (sizeof (cairo_xlib_surface_font_private_t)); - if (!font_private) + if (!font_private) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } if (!_cairo_xlib_add_close_display_hook (dpy, _cairo_xlib_surface_remove_scaled_font, scaled_font, scaled_font)) { free (font_private); + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; } @@ -2642,6 +2650,7 @@ _cairo_xlib_surface_add_glyph (Display *dpy, new = malloc (c); if (new == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); status = CAIRO_STATUS_NO_MEMORY; goto BAIL; } @@ -2769,8 +2778,10 @@ _cairo_xlib_surface_emit_glyphs_chunk (cairo_xlib_surface_t *dst, elts = stack_elts; } else { elts = _cairo_malloc_ab (num_elts, sizeof (XGlyphElt8)); - if (elts == NULL) + if (elts == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return CAIRO_STATUS_NO_MEMORY; + } } /* Fill them in */ diff --git a/src/cairo.c b/src/cairo.c index 8652b28d..4e3bfda4 100644 --- a/src/cairo.c +++ b/src/cairo.c @@ -196,8 +196,10 @@ cairo_create (cairo_surface_t *target) return (cairo_t *) &_cairo_nil; cr = malloc (sizeof (cairo_t)); - if (cr == NULL) + if (cr == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return (cairo_t *) &_cairo_nil; + } CAIRO_REFERENCE_COUNT_INIT (&cr->ref_count, 1); @@ -2414,8 +2416,11 @@ _cairo_rectangle_list_create_in_error (cairo_status_t status) return (cairo_rectangle_list_t*) &_cairo_rectangles_nil; list = malloc (sizeof (cairo_rectangle_list_t)); - if (list == NULL) + if (list == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); return (cairo_rectangle_list_t*) &_cairo_rectangles_nil; + } + list->status = status; list->rectangles = NULL; list->num_rectangles = 0; diff --git a/src/test-meta-surface.c b/src/test-meta-surface.c index 3992b4c6..82fde5fc 100644 --- a/src/test-meta-surface.c +++ b/src/test-meta-surface.c @@ -76,8 +76,10 @@ _cairo_test_meta_surface_create (cairo_content_t content, test_meta_surface_t *surface; surface = malloc (sizeof (test_meta_surface_t)); - if (surface == NULL) + if (surface == NULL) { + _cairo_error (CAIRO_STATUS_NO_MEMORY); goto FAIL; + } _cairo_surface_init (&surface->base, &test_meta_surface_backend, content); |