diff --git a/drivers/gles_common/rasterizer_canvas_batcher.h b/drivers/gles_common/rasterizer_canvas_batcher.h index fce51a72895..61622bac9c6 100644 --- a/drivers/gles_common/rasterizer_canvas_batcher.h +++ b/drivers/gles_common/rasterizer_canvas_batcher.h @@ -1539,8 +1539,9 @@ bool C_PREAMBLE::_prefill_polygon(RasterizerCanvas::Item::CommandPolygon *p_poly int num_inds = p_poly->indices.size(); // nothing to draw? - if (!num_inds) + if (!num_inds || !p_poly->points.size()) { return false; + } // we aren't using indices, so will transform verts more than once .. less efficient. // could be done with a temporary vertex buffer @@ -1667,6 +1668,13 @@ bool C_PREAMBLE::_prefill_polygon(RasterizerCanvas::Item::CommandPolygon *p_poly RAST_DEV_DEBUG_ASSERT(ind < p_poly->points.size()); + // recover at runtime from invalid polys (the editor may send invalid polys) + if ((unsigned int)ind >= (unsigned int)num_verts) { + // will recover as long as there is at least one vertex. + // if there are no verts, we will have quick rejected earlier in this function + ind = 0; + } + // this could be moved outside the loop if (software_transform) { Vector2 pos = p_poly->points[ind]; @@ -1807,6 +1815,14 @@ PREAMBLE(bool)::_software_skin_poly(RasterizerCanvas::Item::CommandPolygon *p_po int ind = p_poly->indices[n]; RAST_DEV_DEBUG_ASSERT(ind < num_verts); + + // recover at runtime from invalid polys (the editor may send invalid polys) + if ((unsigned int)ind >= (unsigned int)num_verts) { + // will recover as long as there is at least one vertex. + // if there are no verts, we will have quick rejected earlier in this function + ind = 0; + } + const Point2 &pos = pTemps[ind]; bvs[n].pos.set(pos.x, pos.y);