From 9bdf4e6916e7ca749730edbe642cc36ca86b34ad Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Thu, 1 Apr 2021 16:46:36 +0900 Subject: [PATCH] evas vg: + null check for safety Change-Id: I097a396f3e2bff6a1cff6718b66e3d1fe275e767 --- src/lib/evas/canvas/efl_canvas_vg_gradient.c | 2 ++ src/lib/evas/canvas/efl_canvas_vg_shape.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/lib/evas/canvas/efl_canvas_vg_gradient.c b/src/lib/evas/canvas/efl_canvas_vg_gradient.c index 427656a..869fa6a 100644 --- a/src/lib/evas/canvas/efl_canvas_vg_gradient.c +++ b/src/lib/evas/canvas/efl_canvas_vg_gradient.c @@ -59,6 +59,8 @@ _gradient_stop_get(Evas_Vg_Gradient *obj, Efl_Gfx_Gradient_Stop **colors, unsign *length = len; *colors = malloc(sizeof(Efl_Gfx_Gradient_Stop) * len); + if (!*colors) return; + for (i = 0; i < len; ++i) { (*colors)[i].offset = stop[i].offset; diff --git a/src/lib/evas/canvas/efl_canvas_vg_shape.c b/src/lib/evas/canvas/efl_canvas_vg_shape.c index 6594663..247c7fa 100644 --- a/src/lib/evas/canvas/efl_canvas_vg_shape.c +++ b/src/lib/evas/canvas/efl_canvas_vg_shape.c @@ -387,6 +387,8 @@ static void _dash_set(Evas_Vg_Shape *obj, const Evas_Vg_Dash *dash, unsigned int length) { float *dash_pattern = malloc(sizeof(float) * length * DASH_PATTERN_EL_SIZE); + if (!dash_pattern) return; + unsigned int i = 0; for (i = 0; i < length; ++i) @@ -1163,6 +1165,7 @@ evas_vg_shape_path_get(Evas_Vg_Shape *obj, const Evas_Vg_Path_Command **op, cons unsigned int i = 0, j = 0; evas_cmds = (Evas_Vg_Path_Command*)malloc(sizeof(Evas_Vg_Path_Command) * (cmds_len + 1)); + if (!evas_cmds) return; for (i = 0; i < cmds_len; ++i) evas_cmds[i] = _get_evas_command(tvg_cmds[i]); @@ -1171,6 +1174,7 @@ evas_vg_shape_path_get(Evas_Vg_Shape *obj, const Evas_Vg_Path_Command **op, cons *op = evas_cmds; evas_pts = (double*)malloc(sizeof(double) * pts_len * 2); + if (!evas_pts) return; for (i = 0; i < pts_len; ++i) { -- 2.7.4