From 4fe8e7214d1c824de5e758f0eef617e4bd370d2a Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Wed, 27 May 2015 17:47:51 -0300 Subject: [PATCH] Error if the rx and ry parameters of love.graphics.rectangle are >= half the rectangle's width or height, respectively. --- src/modules/graphics/opengl/wrap_Graphics.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/graphics/opengl/wrap_Graphics.cpp b/src/modules/graphics/opengl/wrap_Graphics.cpp index c1c9358e7..05b3d8ee6 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.cpp +++ b/src/modules/graphics/opengl/wrap_Graphics.cpp @@ -1535,6 +1535,11 @@ int w_rectangle(lua_State *L) float rx = (float)luaL_optnumber(L, 6, 0.0); float ry = (float)luaL_optnumber(L, 7, rx); + if (rx >= w / 2.0) + return luaL_error(L, "Invalid rectangle x-axis radius (must be less than half the width)"); + if (ry >= h / 2.0) + return luaL_error(L, "Invalid rectangle y-axis radius (must be less than half the height)"); + int points; if (lua_isnoneornil(L, 8)) points = rx + ry > 20 ? (int)((rx + ry) / 4) : 10;