evas vg: fix compatibility issue. 43/256443/2 accepted/tizen/unified/20210403.020837 submit/tizen/20210402.123708
authorHermet Park <chuneon.park@samsung.com>
Fri, 2 Apr 2021 11:19:33 +0000 (20:19 +0900)
committerHermet Park <chuneon.park@samsung.com>
Fri, 2 Apr 2021 11:37:17 +0000 (11:37 +0000)
evas_vg_shape_path_get() could return the commands value even though
it doens't have any path data.

Change-Id: Ia7d11aefa2a2a2b83ba8c763707fc3e4826209d9

src/lib/evas/canvas/efl_canvas_vg_shape.c

index 1b91b12..e44a4e0 100644 (file)
@@ -1139,47 +1139,49 @@ evas_vg_shape_path_get(Evas_Vg_Shape *obj, const Evas_Vg_Path_Command **op, cons
 {
    if (!op || !points) return;
 #ifdef HAVE_THORVG
+   unsigned int i = 0, j = 0;
    Evas_Vg_Path_Command *evas_cmds = NULL;
    double *evas_pts = NULL;
 
    Tvg_Paint *shape = _get_tvg_shape(obj);
+   if (!shape) return;
 
    const Tvg_Path_Command *tvg_cmds = NULL;
    uint32_t cmds_len = 0;
    tvg_shape_get_path_commands(shape, &tvg_cmds, &cmds_len);
 
-   const Tvg_Point *tvg_pts = NULL;
-   uint32_t pts_len = 0;
-   tvg_shape_get_path_coords(shape, &tvg_pts, &pts_len);
-
-   if (!tvg_cmds || (cmds_len <= 0) || !tvg_pts || (pts_len <= 0))
+   if (cmds_len > 0)
      {
-        *op = NULL;
-        *points = NULL;
-        return;
-     }
-
-   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;
 
-   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]);
 
-   for (i = 0; i < cmds_len; ++i)
-     evas_cmds[i] = _get_evas_command(tvg_cmds[i]);
-
-   evas_cmds[cmds_len] = EVAS_VG_PATH_COMMAND_END;
-   *op = evas_cmds;
+        evas_cmds[cmds_len] = EVAS_VG_PATH_COMMAND_END;
+        *op = evas_cmds;
+     }
+   else *op = NULL;
 
-   evas_pts = (double*)malloc(sizeof(double) * pts_len * 2);
-   if (!evas_pts) return;
+   const Tvg_Point *tvg_pts = NULL;
+   uint32_t pts_len = 0;
+   tvg_shape_get_path_coords(shape, &tvg_pts, &pts_len);
 
-   for (i = 0; i < pts_len; ++i)
+   if (pts_len > 0)
      {
-        evas_pts[j] = tvg_pts[i].x;
-        evas_pts[j+1] = tvg_pts[i].y;
-        j += 2;
+        evas_pts = (double*)malloc(sizeof(double) * pts_len * 2);
+        if (!evas_pts) return;
+
+        for (i = 0; i < pts_len; ++i)
+          {
+             evas_pts[j] = tvg_pts[i].x;
+             evas_pts[j+1] = tvg_pts[i].y;
+             j += 2;
+          }
+        *points = evas_pts;
      }
-   *points = evas_pts;
+   else *points = NULL;
+
 #else
    efl_gfx_path_get(obj, (const Efl_Gfx_Path_Command **)op, points);
 #endif