From 0c3d6fd6c385a78c027e9626317fab7a9a2c0d27 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Mon, 18 Feb 2019 15:17:41 +0900 Subject: [PATCH] evas vg: check for OOM when calloc() Change-Id: I9f0b43ad7d45d8263fa8ab48dca44d43d921a07d --- src/static_libs/vg_common/vg_common_svg.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/static_libs/vg_common/vg_common_svg.c b/src/static_libs/vg_common/vg_common_svg.c index 9c69b14..6b18a0e 100644 --- a/src/static_libs/vg_common/vg_common_svg.c +++ b/src/static_libs/vg_common/vg_common_svg.c @@ -899,6 +899,7 @@ _create_gradient_node(Efl_VG *vg) for (i = 0; i < count; i++) { new_stop = calloc(1, sizeof(Efl_Gfx_Gradient_Stop)); + if (!new_stop) goto oom_error; memcpy(new_stop, stops, sizeof(Efl_Gfx_Gradient_Stop)); grad->stops = eina_list_append(grad->stops, new_stop); stops++; @@ -907,6 +908,7 @@ _create_gradient_node(Efl_VG *vg) { grad->type = SVG_LINEAR_GRADIENT; grad->linear = calloc(1, sizeof(Svg_Linear_Gradient)); + if (!grad->linear) goto oom_error; evas_vg_gradient_linear_start_get(vg, &grad->linear->x1, &grad->linear->y1); evas_vg_gradient_linear_end_get(vg, &grad->linear->x2, &grad->linear->y2); } @@ -914,12 +916,18 @@ _create_gradient_node(Efl_VG *vg) { grad->type = SVG_RADIAL_GRADIENT; grad->radial = calloc(1, sizeof(Svg_Radial_Gradient)); + if (!grad->radial) goto oom_error; evas_vg_gradient_radial_center_get(vg, &grad->radial->cx, &grad->radial->cy); evas_vg_gradient_radial_focal_get(vg, &grad->radial->fx, &grad->radial->fy); grad->radial->r = evas_vg_gradient_radial_radius_get(vg); } return grad; + +oom_error: + ERR("OOM: Failed calloc()"); + return grad; + } static void -- 2.7.4