evas vector: fixed dash getter. 71/250071/3
authorMichal Szczecinski <m.szczecinsk@partner.samsung.com>
Fri, 18 Dec 2020 12:33:16 +0000 (13:33 +0100)
committerHermet Park <chuneon.park@samsung.com>
Mon, 21 Dec 2020 13:28:35 +0000 (13:28 +0000)
Dash properties getter was return wrong values which may cause crashes
or unexpedcted behaviour.

Change-Id: I1f42e40ec69bee219e0e25d19c65090138fbfd3b

src/lib/evas/canvas/efl_canvas_vg_shape.c

index c401e04..91a80b3 100644 (file)
@@ -1055,17 +1055,17 @@ evas_vg_shape_stroke_dash_get(Evas_Vg_Shape *obj, const Evas_Vg_Dash **dash, uns
    tvg_shape_get_stroke_dash(_get_tvg_shape(obj), &dashPattern, &cnt);
    if (!cnt) return;
 
-   d = malloc(sizeof(Evas_Vg_Dash) * cnt / DASH_PATTERN_EL_SIZE);
+   d = calloc(cnt / DASH_PATTERN_EL_SIZE, sizeof(Evas_Vg_Dash));
    if (!d) return;
 
-   for (i = 0; i < cnt; i += DASH_PATTERN_EL_SIZE)
+   for (i = 0; i < cnt / DASH_PATTERN_EL_SIZE; ++i)
      {
-        d[i].length = dashPattern[i];
-        d[i].gap = dashPattern[i+1];
+        d[i].length = dashPattern[2 * i];
+        d[i].gap = dashPattern[(2 * i) + 1];
      }
 
    *dash = d;
-   *length = cnt;
+   *length = cnt / 2;
 #else
    efl_gfx_shape_stroke_dash_get(obj, (const Efl_Gfx_Dash **)dash, length);
 #endif