diff options
author | Moonhee Choi <mh0310.choi@samsung.com> | 2017-02-16 13:37:51 +0900 |
---|---|---|
committer | Moonhee Choi <mh0310.choi@samsung.com> | 2017-02-16 13:44:49 +0900 |
commit | b53aa063fed63dcc990f96e3c010a0afe6348b27 (patch) | |
tree | 2606e13ed34174640ae38c4324468e80414ab7ed | |
parent | 8a4f453c6ae9091976e08944ab646a4b44174dae (diff) | |
download | cairo-accepted/tizen/3.0/tv/20170217.022535.tar.gz cairo-accepted/tizen/3.0/tv/20170217.022535.tar.bz2 cairo-accepted/tizen/3.0/tv/20170217.022535.zip |
Fix the svace issues detected after adding new checkersubmit/tizen_3.0/20170216.045638accepted/tizen/3.0/wearable/20170217.022554accepted/tizen/3.0/tv/20170217.022535accepted/tizen/3.0/mobile/20170217.022348accepted/tizen/3.0/ivi/20170217.022627accepted/tizen/3.0/common/20170217.121816
- Mostly related to memory leak
Change-Id: Ia93093b06bea2f7f868e653f230adca2bed469eb
-rwxr-xr-x[-rw-r--r--] | src/cairo-cff-subset.c | 28 | ||||
-rw-r--r-- | src/cairo-damage.c | 2 | ||||
-rw-r--r-- | src/cairo-evas-gl-context.c | 2 | ||||
-rw-r--r-- | src/cairo-ft-font.c | 1 | ||||
-rw-r--r-- | src/cairo-image-source.c | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | src/cairo-pdf-surface.c | 134 | ||||
-rwxr-xr-x[-rw-r--r--] | src/cairo-recording-surface.c | 42 |
7 files changed, 122 insertions, 89 deletions
diff --git a/src/cairo-cff-subset.c b/src/cairo-cff-subset.c index da49e8e1e..8fc130ef6 100644..100755 --- a/src/cairo-cff-subset.c +++ b/src/cairo-cff-subset.c @@ -1077,19 +1077,24 @@ cairo_cff_font_read_cid_fontdict (cairo_cff_font_t *font, unsigned char *ptr) element = _cairo_array_index (&index, i); status = cff_dict_read (font->fd_dict[i], element->data, element->length); - if (unlikely (status)) + if (unlikely (status)){ + free(font->fd_dict[i]); goto fail; + } operand = cff_dict_get_operands (font->fd_dict[i], PRIVATE_OP, &size); if (operand == NULL) { status = CAIRO_INT_STATUS_UNSUPPORTED; + free(font->fd_dict[i]); goto fail; } operand = decode_integer (operand, &size); decode_integer (operand, &offset); status = cff_dict_init (&font->fd_private_dict[i]); - if (unlikely (status)) - goto fail; + if (unlikely (status)){ + free(font->fd_dict[i]); + goto fail; + } cff_index_init (&font->fd_local_sub_index[i]); status = cairo_cff_font_read_private_dict (font, @@ -1101,19 +1106,28 @@ cairo_cff_font_read_cid_fontdict (cairo_cff_font_t *font, unsigned char *ptr) &font->fd_nominal_width[i], font->data + offset, size); - if (unlikely (status)) - goto fail; + if (unlikely (status)){ + free(font->fd_dict[i]); + free(font->fd_private_dict[i]); + goto fail; + } /* Set integer operand to max value to use max size encoding to reserve * space for any value later */ end_buf = encode_integer_max (buf, 0); end_buf = encode_integer_max (end_buf, 0); status = cff_dict_set_operands (font->fd_dict[i], PRIVATE_OP, buf, end_buf - buf); - if (unlikely (status)) + if (unlikely (status)){ + free(font->fd_dict[i]); + free(font->fd_private_dict[i]); goto fail; + } + + free(font->fd_dict[i]); + free(font->fd_private_dict[i]); } - return CAIRO_STATUS_SUCCESS; + status = CAIRO_STATUS_SUCCESS; fail: cff_index_fini (&index); diff --git a/src/cairo-damage.c b/src/cairo-damage.c index 63191fee9..a6bb2261d 100644 --- a/src/cairo-damage.c +++ b/src/cairo-damage.c @@ -237,5 +237,7 @@ _cairo_damage_reduce (cairo_damage_t *damage) } damage->dirty = 0; + + _cairo_damage_destroy(damage); return damage; } diff --git a/src/cairo-evas-gl-context.c b/src/cairo-evas-gl-context.c index 26f1b3be0..b58bc6d46 100644 --- a/src/cairo-evas-gl-context.c +++ b/src/cairo-evas-gl-context.c @@ -304,7 +304,7 @@ cairo_evas_gl_device_create (Evas_GL *evas_gl, ctx->dummy_surface = evas_gl_pbuffer_surface_create (ctx->evas_gl, evas_cfg, 1, 1, NULL); - //evas_gl_config_free (evas_cfg); + evas_gl_config_free (evas_cfg); if (ctx->dummy_surface == NULL) { free (ctx); diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c index c74eaabb6..94ef2cb5a 100644 --- a/src/cairo-ft-font.c +++ b/src/cairo-ft-font.c @@ -1318,6 +1318,7 @@ _get_bitmap_surface (FT_Bitmap *bitmap, _cairo_debug_check_image_surface_is_defined (&image->base); + free (data); return CAIRO_STATUS_SUCCESS; } diff --git a/src/cairo-image-source.c b/src/cairo-image-source.c index d811d4536..520ea0bbd 100644 --- a/src/cairo-image-source.c +++ b/src/cairo-image-source.c @@ -1475,6 +1475,8 @@ _pixman_image_for_surface (cairo_image_surface_t *dst, pixman_image_set_destroy_function (pixman_image, _acquire_source_cleanup, cleanup); } + + free(cleanup); } if (blurred_surface) { diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c index 04128081c..525923113 100644..100755 --- a/src/cairo-pdf-surface.c +++ b/src/cairo-pdf-surface.c @@ -5497,8 +5497,10 @@ _cairo_pdf_surface_emit_truetype_font_subset (cairo_pdf_surface_t *surface, char *pdf_str; status = _utf8_to_pdf_string (subset.family_name_utf8, &pdf_str); - if (unlikely (status)) + if (unlikely (status)){ + free(subset.string_offsets); return status; + } _cairo_output_stream_printf (surface->output, " /FontFamily %s\n", @@ -6098,8 +6100,10 @@ _cairo_pdf_surface_write_mask_group (cairo_pdf_surface_t *surface, } status = _cairo_pdf_surface_add_smask (surface, gstate_res); - if (unlikely (status)) + if (unlikely (status)){ + free(smask_group); return status; + } status = _cairo_pdf_surface_add_xobject (surface, smask_group->group_res); if (unlikely (status)) @@ -6172,12 +6176,16 @@ _cairo_pdf_surface_write_mask_group (cairo_pdf_surface_t *surface, } status = _cairo_pdf_surface_add_smask (surface, gstate_res); - if (unlikely (status)) + if (unlikely (status)){ + free(smask_group); return status; + } status = _cairo_pdf_surface_add_xobject (surface, smask_group->group_res); - if (unlikely (status)) + if (unlikely (status)){ + free(smask_group); return status; + } _cairo_output_stream_printf (surface->output, "q /s%d gs /x%d Do Q\n", @@ -7031,22 +7039,22 @@ _cairo_pdf_surface_paint (void *abstract_surface, status = _cairo_pattern_create_copy (&group->source, source); if (unlikely (status)) { _cairo_pdf_smask_group_destroy (group); - goto cleanup; + goto cleanup_all; } group->source_res = pattern_res; status = _cairo_pdf_surface_add_smask_group (surface, group); if (unlikely (status)) { _cairo_pdf_smask_group_destroy (group); - goto cleanup; + goto cleanup_all; } status = _cairo_pdf_surface_add_smask (surface, gstate_res); if (unlikely (status)) - goto cleanup; + goto cleanup_all; status = _cairo_pdf_surface_add_xobject (surface, group->group_res); if (unlikely (status)) - goto cleanup; + goto cleanup_all; _cairo_output_stream_printf (surface->output, "q /s%d gs /x%d Do Q\n", @@ -7056,7 +7064,7 @@ _cairo_pdf_surface_paint (void *abstract_surface, status = _cairo_pdf_surface_select_pattern (surface, source, pattern_res, FALSE); if (unlikely (status)) - goto cleanup; + goto cleanup_all; _cairo_output_stream_printf (surface->output, "0 0 %f %f re f\n", @@ -7064,14 +7072,16 @@ _cairo_pdf_surface_paint (void *abstract_surface, status = _cairo_pdf_surface_unselect_pattern (surface); if (unlikely (status)) - goto cleanup; + goto cleanup_all; } - _cairo_composite_rectangles_fini (&extents); - return _cairo_output_stream_get_status (surface->output); + status = _cairo_output_stream_get_status (surface->output); +cleanup_all: + free (group); cleanup: _cairo_composite_rectangles_fini (&extents); + return status; } @@ -7174,46 +7184,47 @@ _cairo_pdf_surface_mask (void *abstract_surface, status = _cairo_pattern_create_copy (&group->source, source); if (unlikely (status)) { _cairo_pdf_smask_group_destroy (group); - goto cleanup; + goto cleanup_all; } status = _cairo_pattern_create_copy (&group->mask, mask); if (unlikely (status)) { _cairo_pdf_smask_group_destroy (group); - goto cleanup; + goto cleanup_all; } group->source_res = _cairo_pdf_surface_new_object (surface); if (group->source_res.id == 0) { _cairo_pdf_smask_group_destroy (group); status = _cairo_error (CAIRO_STATUS_NO_MEMORY); - goto cleanup; + goto cleanup_all; } status = _cairo_pdf_surface_add_smask_group (surface, group); if (unlikely (status)) { _cairo_pdf_smask_group_destroy (group); - goto cleanup; + goto cleanup_all; } status = _cairo_pdf_surface_add_smask (surface, group->group_res); if (unlikely (status)) - goto cleanup; + goto cleanup_all; status = _cairo_pdf_surface_add_xobject (surface, group->source_res); if (unlikely (status)) - goto cleanup; + goto cleanup_all; status = _cairo_pdf_operators_flush (&surface->pdf_operators); if (unlikely (status)) - goto cleanup; + goto cleanup_all; _cairo_output_stream_printf (surface->output, "q /s%d gs /x%d Do Q\n", group->group_res.id, group->source_res.id); - _cairo_composite_rectangles_fini (&extents); - return _cairo_output_stream_get_status (surface->output); + status = _cairo_output_stream_get_status (surface->output); +cleanup_all: + free (group); cleanup: _cairo_composite_rectangles_fini (&extents); return status; @@ -7298,13 +7309,13 @@ _cairo_pdf_surface_stroke (void *abstract_surface, status = _cairo_pattern_create_copy (&group->source, source); if (unlikely (status)) { _cairo_pdf_smask_group_destroy (group); - goto cleanup; + goto cleanup_all; } group->source_res = pattern_res; status = _cairo_path_fixed_init_copy (&group->path, path); if (unlikely (status)) { _cairo_pdf_smask_group_destroy (group); - goto cleanup; + goto cleanup_all; } group->style = *style; @@ -7313,20 +7324,20 @@ _cairo_pdf_surface_stroke (void *abstract_surface, status = _cairo_pdf_surface_add_smask_group (surface, group); if (unlikely (status)) { _cairo_pdf_smask_group_destroy (group); - goto cleanup; + goto cleanup_all; } status = _cairo_pdf_surface_add_smask (surface, gstate_res); if (unlikely (status)) - goto cleanup; + goto cleanup_all; status = _cairo_pdf_surface_add_xobject (surface, group->group_res); if (unlikely (status)) - goto cleanup; + goto cleanup_all; status = _cairo_pdf_operators_flush (&surface->pdf_operators); if (unlikely (status)) - goto cleanup; + goto cleanup_all; _cairo_output_stream_printf (surface->output, "q /s%d gs /x%d Do Q\n", @@ -7335,7 +7346,7 @@ _cairo_pdf_surface_stroke (void *abstract_surface, } else { status = _cairo_pdf_surface_select_pattern (surface, source, pattern_res, TRUE); if (unlikely (status)) - goto cleanup; + goto cleanup_all; status = _cairo_pdf_operators_stroke (&surface->pdf_operators, path, @@ -7343,16 +7354,17 @@ _cairo_pdf_surface_stroke (void *abstract_surface, ctm, ctm_inverse); if (unlikely (status)) - goto cleanup; + goto cleanup_all; status = _cairo_pdf_surface_unselect_pattern (surface); if (unlikely (status)) - goto cleanup; + goto cleanup_all; } - _cairo_composite_rectangles_fini (&extents); - return _cairo_output_stream_get_status (surface->output); + status = _cairo_output_stream_get_status (surface->output); +cleanup_all: + free (group); cleanup: _cairo_composite_rectangles_fini (&extents); return status; @@ -7461,33 +7473,33 @@ _cairo_pdf_surface_fill (void *abstract_surface, status = _cairo_pattern_create_copy (&group->source, source); if (unlikely (status)) { _cairo_pdf_smask_group_destroy (group); - goto cleanup; + goto cleanup_all; } group->source_res = pattern_res; status = _cairo_path_fixed_init_copy (&group->path, path); if (unlikely (status)) { _cairo_pdf_smask_group_destroy (group); - goto cleanup; + goto cleanup_all; } group->fill_rule = fill_rule; status = _cairo_pdf_surface_add_smask_group (surface, group); if (unlikely (status)) { _cairo_pdf_smask_group_destroy (group); - goto cleanup; + goto cleanup_all; } status = _cairo_pdf_surface_add_smask (surface, gstate_res); if (unlikely (status)) - goto cleanup; + goto cleanup_all; status = _cairo_pdf_surface_add_xobject (surface, group->group_res); if (unlikely (status)) - goto cleanup; + goto cleanup_all; status = _cairo_pdf_operators_flush (&surface->pdf_operators); if (unlikely (status)) - goto cleanup; + goto cleanup_all; _cairo_output_stream_printf (surface->output, "q /s%d gs /x%d Do Q\n", @@ -7496,22 +7508,23 @@ _cairo_pdf_surface_fill (void *abstract_surface, } else { status = _cairo_pdf_surface_select_pattern (surface, source, pattern_res, FALSE); if (unlikely (status)) - goto cleanup; + goto cleanup_all; status = _cairo_pdf_operators_fill (&surface->pdf_operators, path, fill_rule); if (unlikely (status)) - goto cleanup; + goto cleanup_all; status = _cairo_pdf_surface_unselect_pattern (surface); if (unlikely (status)) - goto cleanup; + goto cleanup_all; } - _cairo_composite_rectangles_fini (&extents); - return _cairo_output_stream_get_status (surface->output); + status = _cairo_output_stream_get_status (surface->output); +cleanup_all: + free (group); cleanup: _cairo_composite_rectangles_fini (&extents); return status; @@ -7745,7 +7758,7 @@ _cairo_pdf_surface_show_text_glyphs (void *abstract_surface, status = _cairo_pattern_create_copy (&group->source, source); if (unlikely (status)) { _cairo_pdf_smask_group_destroy (group); - goto cleanup; + goto cleanup_group; } group->source_res = pattern_res; @@ -7754,7 +7767,7 @@ _cairo_pdf_surface_show_text_glyphs (void *abstract_surface, if (unlikely (group->utf8 == NULL)) { _cairo_pdf_smask_group_destroy (group); status = _cairo_error (CAIRO_STATUS_NO_MEMORY); - goto cleanup; + goto cleanup_group; } memcpy (group->utf8, utf8, utf8_len); } @@ -7765,7 +7778,7 @@ _cairo_pdf_surface_show_text_glyphs (void *abstract_surface, if (unlikely (group->glyphs == NULL)) { _cairo_pdf_smask_group_destroy (group); status = _cairo_error (CAIRO_STATUS_NO_MEMORY); - goto cleanup; + goto cleanup_utf8; } memcpy (group->glyphs, glyphs, sizeof (cairo_glyph_t) * num_glyphs); } @@ -7776,7 +7789,7 @@ _cairo_pdf_surface_show_text_glyphs (void *abstract_surface, if (unlikely (group->clusters == NULL)) { _cairo_pdf_smask_group_destroy (group); status = _cairo_error (CAIRO_STATUS_NO_MEMORY); - goto cleanup; + goto cleanup_glyphs; } memcpy (group->clusters, clusters, sizeof (cairo_text_cluster_t) * num_clusters); } @@ -7786,20 +7799,20 @@ _cairo_pdf_surface_show_text_glyphs (void *abstract_surface, status = _cairo_pdf_surface_add_smask_group (surface, group); if (unlikely (status)) { _cairo_pdf_smask_group_destroy (group); - goto cleanup; + goto cleanup_all; } status = _cairo_pdf_surface_add_smask (surface, gstate_res); if (unlikely (status)) - goto cleanup; + goto cleanup_all; status = _cairo_pdf_surface_add_xobject (surface, group->group_res); if (unlikely (status)) - goto cleanup; + goto cleanup_all; status = _cairo_pdf_operators_flush (&surface->pdf_operators); if (unlikely (status)) - goto cleanup; + goto cleanup_all; _cairo_output_stream_printf (surface->output, "q /s%d gs /x%d Do Q\n", @@ -7808,7 +7821,7 @@ _cairo_pdf_surface_show_text_glyphs (void *abstract_surface, } else { status = _cairo_pdf_surface_select_pattern (surface, source, pattern_res, FALSE); if (unlikely (status)) - goto cleanup; + goto cleanup_all; /* Each call to show_glyphs() with a transclucent pattern must * be in a separate text object otherwise overlapping text @@ -7817,7 +7830,7 @@ _cairo_pdf_surface_show_text_glyphs (void *abstract_surface, if (! _cairo_pattern_is_opaque (source, &extents.bounded)) { status = _cairo_pdf_operators_flush (&surface->pdf_operators); if (unlikely (status)) - goto cleanup; + goto cleanup_all; } status = _cairo_pdf_operators_show_text_glyphs (&surface->pdf_operators, @@ -7827,16 +7840,21 @@ _cairo_pdf_surface_show_text_glyphs (void *abstract_surface, cluster_flags, scaled_font); if (unlikely (status)) - goto cleanup; + goto cleanup_all; status = _cairo_pdf_surface_unselect_pattern (surface); if (unlikely (status)) - goto cleanup; + goto cleanup_all; } - _cairo_composite_rectangles_fini (&extents); - return _cairo_output_stream_get_status (surface->output); - +cleanup_all: + free(group->clusters); +cleanup_glyphs: + free(group->glyphs); +cleanup_utf8: + free(group->utf8); +cleanup_group: + free(group); cleanup: _cairo_composite_rectangles_fini (&extents); return status; diff --git a/src/cairo-recording-surface.c b/src/cairo-recording-surface.c index ee9304746..ba51fc349 100644..100755 --- a/src/cairo-recording-surface.c +++ b/src/cairo-recording-surface.c @@ -765,8 +765,7 @@ _cairo_recording_surface_paint (void *abstract_surface, _cairo_recording_surface_destroy_bbtree (surface); - _cairo_composite_rectangles_fini (&composite); - return CAIRO_STATUS_SUCCESS; + status = CAIRO_STATUS_SUCCESS; CLEANUP_SOURCE: _cairo_pattern_fini (&command->source.base); @@ -825,8 +824,7 @@ _cairo_recording_surface_mask (void *abstract_surface, _cairo_recording_surface_destroy_bbtree (surface); - _cairo_composite_rectangles_fini (&composite); - return CAIRO_STATUS_SUCCESS; + status = CAIRO_STATUS_SUCCESS; CLEANUP_MASK: _cairo_pattern_fini (&command->mask.base); @@ -902,8 +900,7 @@ _cairo_recording_surface_stroke (void *abstract_surface, _cairo_recording_surface_destroy_bbtree (surface); - _cairo_composite_rectangles_fini (&composite); - return CAIRO_STATUS_SUCCESS; + status = CAIRO_STATUS_SUCCESS; CLEANUP_STYLE: _cairo_stroke_style_fini (&command->style); @@ -973,8 +970,7 @@ _cairo_recording_surface_fill (void *abstract_surface, _cairo_recording_surface_destroy_bbtree (surface); - _cairo_composite_rectangles_fini (&composite); - return CAIRO_STATUS_SUCCESS; + status = CAIRO_STATUS_SUCCESS; CLEANUP_PATH: _cairo_path_fixed_fini (&command->path); @@ -1052,7 +1048,7 @@ _cairo_recording_surface_show_text_glyphs (void *abstract_surface, command->utf8 = malloc (utf8_len); if (unlikely (command->utf8 == NULL)) { status = _cairo_error (CAIRO_STATUS_NO_MEMORY); - goto CLEANUP_ARRAYS; + goto CLEANUP_SOURCE; } memcpy (command->utf8, utf8, utf8_len); } @@ -1060,7 +1056,7 @@ _cairo_recording_surface_show_text_glyphs (void *abstract_surface, command->glyphs = _cairo_malloc_ab (num_glyphs, sizeof (glyphs[0])); if (unlikely (command->glyphs == NULL)) { status = _cairo_error (CAIRO_STATUS_NO_MEMORY); - goto CLEANUP_ARRAYS; + goto CLEANUP_UTF8; } memcpy (command->glyphs, glyphs, sizeof (glyphs[0]) * num_glyphs); } @@ -1068,7 +1064,7 @@ _cairo_recording_surface_show_text_glyphs (void *abstract_surface, command->clusters = _cairo_malloc_ab (num_clusters, sizeof (clusters[0])); if (unlikely (command->clusters == NULL)) { status = _cairo_error (CAIRO_STATUS_NO_MEMORY); - goto CLEANUP_ARRAYS; + goto CLEANUP_GLYPHS; } memcpy (command->clusters, clusters, sizeof (clusters[0]) * num_clusters); } @@ -1081,17 +1077,17 @@ _cairo_recording_surface_show_text_glyphs (void *abstract_surface, if (unlikely (status)) goto CLEANUP_SCALED_FONT; - _cairo_composite_rectangles_fini (&composite); - return CAIRO_STATUS_SUCCESS; + status = CAIRO_STATUS_SUCCESS; CLEANUP_SCALED_FONT: cairo_scaled_font_destroy (command->scaled_font); - CLEANUP_ARRAYS: + free (command->clusters); + CLEANUP_GLYPHS: + free (command->glyphs); + CLEANUP_UTF8: free (command->utf8); - free (command->glyphs); - free (command->clusters); - - _cairo_pattern_fini (&command->source.base); + CLEANUP_SOURCE: + _cairo_pattern_fini (&command->source.base); CLEANUP_COMMAND: _cairo_clip_destroy (command->header.clip); free (command); @@ -1140,7 +1136,7 @@ _cairo_recording_surface_copy__paint (cairo_recording_surface_t *surface, if (unlikely (status)) goto err_source; - return CAIRO_STATUS_SUCCESS; + status = CAIRO_STATUS_SUCCESS; err_source: _cairo_pattern_fini (&command->source.base); @@ -1179,7 +1175,7 @@ _cairo_recording_surface_copy__mask (cairo_recording_surface_t *surface, if (unlikely (status)) goto err_mask; - return CAIRO_STATUS_SUCCESS; + status = CAIRO_STATUS_SUCCESS; err_mask: _cairo_pattern_fini (&command->mask.base); @@ -1229,7 +1225,7 @@ _cairo_recording_surface_copy__stroke (cairo_recording_surface_t *surface, if (unlikely (status)) goto err_style; - return CAIRO_STATUS_SUCCESS; + status = CAIRO_STATUS_SUCCESS; err_style: _cairo_stroke_style_fini (&command->style); @@ -1275,7 +1271,7 @@ _cairo_recording_surface_copy__fill (cairo_recording_surface_t *surface, if (unlikely (status)) goto err_path; - return CAIRO_STATUS_SUCCESS; + status = CAIRO_STATUS_SUCCESS; err_path: _cairo_path_fixed_fini (&command->path); @@ -1352,7 +1348,7 @@ _cairo_recording_surface_copy__glyphs (cairo_recording_surface_t *surface, if (unlikely (status)) goto err_arrays; - return CAIRO_STATUS_SUCCESS; + status = CAIRO_STATUS_SUCCESS; err_arrays: free (command->utf8); |