/* r, r0, r1 are distance along gradient vector */
gradient_norm_squared = gradient_dx * gradient_dx +
gradient_dy * gradient_dy;
- pts = svgtiny_list_create(
- sizeof (struct grad_point));
+ pts = svgtiny_list_create(sizeof (struct grad_point));
if (!pts)
return svgtiny_OUT_OF_MEMORY;
for (j = 0; j != n; ) {
svgtiny_list_size(pts), min_pt, min_r);
#endif
+ /* There must be at least a single point for the gradient */
+ if (svgtiny_list_size(pts) == 0) {
+ svgtiny_list_free(pts);
+
+ return svgtiny_OK;
+ }
+
/* render triangles */
stop_count = state->linear_gradient_stop_count;
assert(2 <= stop_count);
/* render triangle vertices with r values for debugging */
#ifdef GRADIENT_DEBUG
- for (unsigned int i = 0; i != pts->size; i++) {
+ for (unsigned int i = 0; i != svgtiny_list_size(pts); i++) {
struct grad_point *point = svgtiny_list_get(pts, i);
struct svgtiny_shape *shape = svgtiny_add_shape(state);
if (!shape)