From 4043f71156a7149f8d4bafe15d3ac73c440fae7b Mon Sep 17 00:00:00 2001 From: binary1248 Date: Wed, 20 Feb 2019 20:09:33 +0100 Subject: [PATCH] Fixed missing checks for empty vertex arrays when updating the vertex buffers in sf::Text. (Fixes #1558) --- src/SFML/Graphics/Text.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/SFML/Graphics/Text.cpp b/src/SFML/Graphics/Text.cpp index 5b9294858..64e0dacc9 100644 --- a/src/SFML/Graphics/Text.cpp +++ b/src/SFML/Graphics/Text.cpp @@ -212,7 +212,8 @@ void Text::setFillColor(const Color& color) if (m_verticesBuffer.getVertexCount() != m_vertices.getVertexCount()) m_verticesBuffer.create(m_vertices.getVertexCount()); - m_verticesBuffer.update(&m_vertices[0]); + if (m_vertices.getVertexCount() > 0) + m_verticesBuffer.update(&m_vertices[0]); } } } @@ -238,7 +239,8 @@ void Text::setOutlineColor(const Color& color) if (m_outlineVerticesBuffer.getVertexCount() != m_outlineVertices.getVertexCount()) m_outlineVerticesBuffer.create(m_outlineVertices.getVertexCount()); - m_outlineVerticesBuffer.update(&m_outlineVertices[0]); + if (m_outlineVertices.getVertexCount() > 0) + m_outlineVerticesBuffer.update(&m_outlineVertices[0]); } } } @@ -617,12 +619,14 @@ void Text::ensureGeometryUpdate() const if (m_verticesBuffer.getVertexCount() != m_vertices.getVertexCount()) m_verticesBuffer.create(m_vertices.getVertexCount()); - m_verticesBuffer.update(&m_vertices[0]); + if (m_vertices.getVertexCount() > 0) + m_verticesBuffer.update(&m_vertices[0]); if (m_outlineVerticesBuffer.getVertexCount() != m_outlineVertices.getVertexCount()) m_outlineVerticesBuffer.create(m_outlineVertices.getVertexCount()); - m_outlineVerticesBuffer.update(&m_outlineVertices[0]); + if (m_outlineVertices.getVertexCount() > 0) + m_outlineVerticesBuffer.update(&m_outlineVertices[0]); } }