efl: prevent segv while interpolating empty shape.
authorCedric BAIL <cedric@osg.samsung.com>
Sat, 4 Jul 2015 00:23:17 +0000 (02:23 +0200)
committerCedric BAIL <cedric@osg.samsung.com>
Fri, 21 Aug 2015 14:40:32 +0000 (16:40 +0200)
src/lib/efl/interfaces/efl_gfx_shape.c

index efbc9d5..a01c62d 100644 (file)
@@ -255,6 +255,7 @@ _efl_gfx_shape_equal_commands_internal(Efl_Gfx_Shape_Data *a,
    unsigned int i;
 
    if (a->commands_count != b->commands_count) return EINA_FALSE;
+   if (a->commands_count <= 0) return EINA_TRUE;
 
    for (i = 0; a->commands[i] == b->commands[i] &&
           a->commands[i] != EFL_GFX_PATH_COMMAND_TYPE_END; i++)
@@ -337,21 +338,24 @@ _efl_gfx_shape_interpolate(Eo *obj, Efl_Gfx_Shape_Data *pd,
    if (!pts && from_pd->points_count) return EINA_FALSE;
    pd->points = pts;
 
-   memcpy(cmds, from_pd->commands,
-          sizeof (Efl_Gfx_Path_Command) * from_pd->commands_count);
+   if (cmds)
+     {
+        memcpy(cmds, from_pd->commands,
+               sizeof (Efl_Gfx_Path_Command) * from_pd->commands_count);
 
-   to_pts = to_pd->points;
-   from_pts = from_pd->points;
+        to_pts = to_pd->points;
+        from_pts = from_pd->points;
 
-   for (i = 0; cmds[i] != EFL_GFX_PATH_COMMAND_TYPE_END; i++)
-     for (j = 0; j < _efl_gfx_path_command_length(cmds[i]); j++)
-       {
-          *pts = interpolate(*from_pts, *to_pts, pos_map);
+        for (i = 0; cmds[i] != EFL_GFX_PATH_COMMAND_TYPE_END; i++)
+          for (j = 0; j < _efl_gfx_path_command_length(cmds[i]); j++)
+            {
+               *pts = interpolate(*from_pts, *to_pts, pos_map);
 
-          pts++;
-          from_pts++;
-          to_pts++;
-       }
+               pts++;
+               from_pts++;
+               to_pts++;
+            }
+     }
 
    pd->points_count = from_pd->points_count;
    pd->commands_count = from_pd->commands_count;