From de3ea71631b8d061ebe51d7e3bb1a56b73057473 Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Sat, 30 Nov 2013 20:57:18 +0100 Subject: [PATCH] Fixed divide by zero in Shape.cpp (#499) --- src/SFML/Graphics/Shape.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SFML/Graphics/Shape.cpp b/src/SFML/Graphics/Shape.cpp index 16524f5e9..b979635f6 100644 --- a/src/SFML/Graphics/Shape.cpp +++ b/src/SFML/Graphics/Shape.cpp @@ -240,8 +240,8 @@ void Shape::updateTexCoords() { for (unsigned int i = 0; i < m_vertices.getVertexCount(); ++i) { - float xratio = (m_vertices[i].position.x - m_insideBounds.left) / m_insideBounds.width; - float yratio = (m_vertices[i].position.y - m_insideBounds.top) / m_insideBounds.height; + float xratio = m_insideBounds.width > 0 ? (m_vertices[i].position.x - m_insideBounds.left) / m_insideBounds.width : 0; + float yratio = m_insideBounds.height > 0 ? (m_vertices[i].position.y - m_insideBounds.top) / m_insideBounds.height : 0; m_vertices[i].texCoords.x = m_textureRect.left + m_textureRect.width * xratio; m_vertices[i].texCoords.y = m_textureRect.top + m_textureRect.height * yratio; }