Merge pull request #17637 from robfram/fix-draw_polyline_colors-crash

Fix crash in `canvas_item_add_polyline` when passing more points than colors
This commit is contained in:
Rémi Verschelde 2018-03-20 11:23:15 +01:00 committed by GitHub
commit a238e53da9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -440,13 +440,17 @@ void VisualServerCanvas::canvas_item_add_polyline(RID p_item, const Vector<Point
if (p_antialiased) {
pline->line_colors.push_back(Color(1, 1, 1, 1));
}
}
if (p_colors.size() == 1) {
} else if (p_colors.size() == 1) {
pline->triangle_colors = p_colors;
pline->line_colors = p_colors;
} else {
pline->triangle_colors.resize(pline->triangles.size());
pline->line_colors.resize(pline->lines.size());
if (p_colors.size() != p_points.size()) {
pline->triangle_colors.push_back(p_colors[0]);
pline->line_colors.push_back(p_colors[0]);
} else {
pline->triangle_colors.resize(pline->triangles.size());
pline->line_colors.resize(pline->lines.size());
}
}
for (int i = 0; i < p_points.size(); i++) {