Fix svace issue 37/283937/1 tizen_7.0
authortscholb <scholb.kim@samsung.com>
Mon, 7 Nov 2022 10:31:49 +0000 (19:31 +0900)
committertscholb <scholb.kim@samsung.com>
Mon, 7 Nov 2022 10:41:09 +0000 (19:41 +0900)
- malloc() to _cairo _malloc()

Change-Id: Ib3a8b49c9cda6173d8c9e7afd213b329650df638

src/cairo-cff-subset.c
src/cairo-font-face-twin.c
src/cairo-font-options.c
src/cairo-truetype-subset.c

index 1de08e1..cbf7c8d 100644 (file)
@@ -577,7 +577,7 @@ cff_index_append_copy (cairo_array_t *index,
 
     element.length = length;
     element.is_copy = TRUE;
-    element.data = malloc (element.length);
+    element.data = _cairo_malloc (element.length);
     if (unlikely (element.data == NULL))
        return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -640,12 +640,12 @@ cff_dict_create_operator (int            operator,
 {
     cff_dict_operator_t *op;
 
-    op = malloc (sizeof (cff_dict_operator_t));
+    op = _cairo_malloc (sizeof (cff_dict_operator_t));
     if (unlikely (op == NULL))
        return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     _cairo_dict_init_key (op, operator);
-    op->operand = malloc (size);
+    op->operand = _cairo_malloc (size);
     if (unlikely (op->operand == NULL)) {
         free (op);
        return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -746,7 +746,7 @@ cff_dict_set_operands (cairo_hash_table_t *dict,
     op = _cairo_hash_table_lookup (dict, &key.base);
     if (op != NULL) {
         free (op->operand);
-        op->operand = malloc (size);
+        op->operand = _cairo_malloc (size);
        if (unlikely (op->operand == NULL))
            return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -903,7 +903,7 @@ cairo_cff_font_read_name (cairo_cff_font_t *font)
                len -= 7;
            }
        }
-        font->ps_name = malloc (len + 1);
+        font->ps_name = _cairo_malloc (len + 1);
         if (unlikely (font->ps_name == NULL))
             return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -1919,7 +1919,7 @@ cairo_cff_font_create_cid_fontdict (cairo_cff_font_t *font)
     cairo_status_t status;
 
     font->num_fontdicts = 1;
-    font->fd_dict = malloc (sizeof (cairo_hash_table_t *));
+    font->fd_dict = _cairo_malloc (sizeof (cairo_hash_table_t *));
     if (unlikely (font->fd_dict == NULL))
        return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -1930,11 +1930,11 @@ cairo_cff_font_create_cid_fontdict (cairo_cff_font_t *font)
        return _cairo_error (CAIRO_STATUS_NO_MEMORY);
     }
 
-    font->fd_subset_map = malloc (sizeof (int));
+    font->fd_subset_map = _cairo_malloc (sizeof (int));
     if (unlikely (font->fd_subset_map == NULL))
        return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
-    font->private_dict_offset = malloc (sizeof (int));
+    font->private_dict_offset = _cairo_malloc (sizeof (int));
     if (unlikely (font->private_dict_offset == NULL))
        return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -2029,7 +2029,7 @@ cairo_cff_font_subset_font (cairo_cff_font_t  *font)
        if (unlikely (status))
            return status;
     }  else {
-       font->private_dict_offset = malloc (sizeof (int));
+       font->private_dict_offset = _cairo_malloc (sizeof (int));
        if (unlikely (font->private_dict_offset == NULL))
            return _cairo_error (CAIRO_STATUS_NO_MEMORY);
     }
@@ -2621,7 +2621,7 @@ cairo_cff_font_generate (cairo_cff_font_t  *font,
 
     /* If the PS name is not found, create a CairoFont-x-y name. */
     if (font->ps_name == NULL) {
-        font->ps_name = malloc (30);
+        font->ps_name = _cairo_malloc (30);
         if (unlikely (font->ps_name == NULL))
            return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -2806,7 +2806,7 @@ _cairo_cff_font_load_cff (cairo_cff_font_t  *font)
     font->font_name = NULL;
     font->is_opentype = FALSE;
     font->data_length = data_length;
-    font->data = malloc (data_length);
+    font->data = _cairo_malloc (data_length);
     if (unlikely (font->data == NULL))
         return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -3035,7 +3035,7 @@ _cairo_cff_subset_init (cairo_cff_subset_t          *cff_subset,
     cff_subset->ascent = (double)font->ascent/font->units_per_em;
     cff_subset->descent = (double)font->descent/font->units_per_em;
 
-    cff_subset->data = malloc (length);
+    cff_subset->data = _cairo_malloc (length);
     if (unlikely (cff_subset->data == NULL)) {
        status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
        goto fail4;
@@ -3094,7 +3094,7 @@ _cairo_cff_scaled_font_is_cid_cff (cairo_scaled_font_t *scaled_font)
        (status = backend->load_truetype_table (scaled_font, TT_TAG_CFF,
                                                0, NULL, &data_length)) == CAIRO_INT_STATUS_SUCCESS)
     {
-       data = malloc (data_length);
+       data = _cairo_malloc (data_length);
        if (unlikely (data == NULL)) {
            status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
            return FALSE;
@@ -3111,7 +3111,7 @@ _cairo_cff_scaled_font_is_cid_cff (cairo_scaled_font_t *scaled_font)
        (status = backend->load_type1_data (scaled_font,
                                            0, NULL, &data_length)) == CAIRO_INT_STATUS_SUCCESS)
     {
-       data = malloc (data_length);
+       data = _cairo_malloc (data_length);
        if (unlikely (data == NULL)) {
            status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
            return FALSE;
@@ -3189,7 +3189,7 @@ _cairo_cff_font_fallback_create (cairo_scaled_font_subset_t  *scaled_font_subset
     cairo_status_t status;
     cairo_cff_font_t *font;
 
-    font = malloc (sizeof (cairo_cff_font_t));
+    font = _cairo_malloc (sizeof (cairo_cff_font_t));
     if (unlikely (font == NULL))
        return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -3373,7 +3373,7 @@ cairo_cff_font_fallback_generate (cairo_cff_font_t           *font,
        if (unlikely (status))
            return status;
     } else {
-       font->private_dict_offset = malloc (sizeof (int));
+       font->private_dict_offset = _cairo_malloc (sizeof (int));
        if (unlikely (font->private_dict_offset == NULL))
            return _cairo_error (CAIRO_STATUS_NO_MEMORY);
     }
@@ -3452,7 +3452,7 @@ _cairo_cff_fallback_init (cairo_cff_subset_t          *cff_subset,
     cff_subset->ascent = (double)type2_subset.y_max/1000;
     cff_subset->descent = (double)type2_subset.y_min/1000;
 
-    cff_subset->data = malloc (length);
+    cff_subset->data = _cairo_malloc (length);
     if (unlikely (cff_subset->data == NULL)) {
        status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
        goto fail4;
index 22f8739..4e7f979 100644 (file)
@@ -288,7 +288,7 @@ twin_font_face_create_properties (cairo_font_face_t *twin_face)
 {
     twin_face_properties_t *props;
 
-    props = malloc (sizeof (twin_face_properties_t));
+    props = _cairo_malloc (sizeof (twin_face_properties_t));
     if (unlikely (props == NULL))
        return NULL;
 
@@ -412,7 +412,7 @@ twin_scaled_font_compute_properties (cairo_scaled_font_t *scaled_font,
     cairo_status_t status;
     twin_scaled_properties_t *props;
 
-    props = malloc (sizeof (twin_scaled_properties_t));
+    props = _cairo_malloc (sizeof (twin_scaled_properties_t));
     if (unlikely (props == NULL))
        return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
index d8883a5..39f0ec4 100644 (file)
@@ -108,7 +108,7 @@ cairo_font_options_create (void)
 {
     cairo_font_options_t *options;
 
-    options = malloc (sizeof (cairo_font_options_t));
+    options = _cairo_malloc (sizeof (cairo_font_options_t));
     if (!options) {
        _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
        return (cairo_font_options_t *) &_cairo_font_options_nil;
@@ -142,7 +142,7 @@ cairo_font_options_copy (const cairo_font_options_t *original)
     if (cairo_font_options_status ((cairo_font_options_t *) original))
        return (cairo_font_options_t *) &_cairo_font_options_nil;
 
-    options = malloc (sizeof (cairo_font_options_t));
+    options = _cairo_malloc (sizeof (cairo_font_options_t));
     if (!options) {
        _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
        return (cairo_font_options_t *) &_cairo_font_options_nil;
index 17e33ae..4d58080 100644 (file)
@@ -187,7 +187,7 @@ _cairo_truetype_font_create (cairo_scaled_font_subset_t  *scaled_font_subset,
     if (unlikely (status))
        return status;
 
-    font = malloc (sizeof (cairo_truetype_font_t));
+    font = _cairo_malloc (sizeof (cairo_truetype_font_t));
     if (unlikely (font == NULL))
        return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -236,7 +236,7 @@ _cairo_truetype_font_create (cairo_scaled_font_subset_t  *scaled_font_subset,
 
     /* If the PS name is not found, create a CairoFont-x-y name. */
     if (font->base.ps_name == NULL) {
-        font->base.ps_name = malloc (30);
+        font->base.ps_name = _cairo_malloc (30);
         if (unlikely (font->base.ps_name == NULL)) {
            status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
             goto fail3;
@@ -611,7 +611,7 @@ cairo_truetype_font_write_glyf_table (cairo_truetype_font_t *font,
     else
        size = sizeof (int32_t) * (font->num_glyphs_in_face + 1);
 
-    u.bytes = malloc (size);
+    u.bytes = _cairo_malloc (size);
     if (unlikely (u.bytes == NULL))
        return _cairo_truetype_font_set_error (font, CAIRO_STATUS_NO_MEMORY);
 
@@ -1174,7 +1174,7 @@ cairo_truetype_subset_init_internal (cairo_truetype_subset_t     *truetype_subse
     truetype_subset->descent = (double)font->base.descent/font->base.units_per_em;
 
     if (length) {
-       truetype_subset->data = malloc (length);
+       truetype_subset->data = _cairo_malloc (length);
        if (unlikely (truetype_subset->data == NULL)) {
            status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
            goto fail4;
@@ -1187,7 +1187,7 @@ cairo_truetype_subset_init_internal (cairo_truetype_subset_t     *truetype_subse
 
     if (num_strings) {
        offsets_length = num_strings * sizeof (unsigned long);
-       truetype_subset->string_offsets = malloc (offsets_length);
+       truetype_subset->string_offsets = _cairo_malloc (offsets_length);
        if (unlikely (truetype_subset->string_offsets == NULL)) {
            status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
            goto fail5;
@@ -1446,7 +1446,7 @@ find_name (tt_name_t *name, int name_id, int platform, int encoding, int languag
        for (i = 0; i < u_len; i++)
            size += _cairo_ucs4_to_utf8 (be16_to_cpu(u[i]), NULL);
 
-       utf8 = malloc (size + 1);
+       utf8 = _cairo_malloc (size + 1);
        if (utf8 == NULL) {
            status =_cairo_error (CAIRO_STATUS_NO_MEMORY);
            goto fail;
@@ -1481,7 +1481,7 @@ find_name (tt_name_t *name, int name_id, int platform, int encoding, int languag
        }
     }
     if (has_tag) {
-       p = malloc (len - 6);
+       p = _cairo_malloc (len - 6);
        if (unlikely (p == NULL)) {
            status =_cairo_error (CAIRO_STATUS_NO_MEMORY);
            goto fail;
@@ -1526,7 +1526,7 @@ _cairo_truetype_read_font_name (cairo_scaled_font_t        *scaled_font,
     if (status)
        return status;
 
-    name = malloc (size);
+    name = _cairo_malloc (size);
     if (name == NULL)
         return _cairo_error (CAIRO_STATUS_NO_MEMORY);