gfx: Add NULL check to silence coverity
authorJean-Philippe Andre <jp.andre@samsung.com>
Wed, 13 Jul 2016 07:16:02 +0000 (16:16 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Wed, 13 Jul 2016 07:18:54 +0000 (16:18 +0900)
realloc() can return NULL if size is 0. It's like free().
So, the usage here is correct, and there are probably no
points to interpolate between anyway. I wonder if there
can be commands without points, though.

Fixes CID 1293004

src/lib/efl/interfaces/efl_gfx_shape.c

index 415265f..11b38a6 100644 (file)
@@ -318,7 +318,7 @@ _efl_gfx_shape_interpolate(Eo *obj, Efl_Gfx_Shape_Data *pd,
    Efl_Gfx_Path_Command *cmds;
    Efl_Gfx_Property property_from, property_to;
    Efl_Gfx_Dash *dash = NULL;
-   double *pts, *from_pts, *to_pts;
+   double *pts;
    unsigned int i, j;
 
    from_pd = eo_data_scope_get(from, EFL_GFX_SHAPE_MIXIN);
@@ -351,18 +351,21 @@ _efl_gfx_shape_interpolate(Eo *obj, Efl_Gfx_Shape_Data *pd,
         memcpy(cmds, from_pd->commands,
                sizeof (Efl_Gfx_Path_Command) * from_pd->commands_count);
 
-        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);
-
-               pts++;
-               from_pts++;
-               to_pts++;
-            }
+        if (pts)
+          {
+             double *to_pts = to_pd->points;
+             double *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);
+
+                    pts++;
+                    from_pts++;
+                    to_pts++;
+                 }
+          }
      }
 
    pd->points_count = from_pd->points_count;