From e1baf02b7a3f2dd27ccf8bcf6089c5d765dfe756 Mon Sep 17 00:00:00 2001
From: Monster Iestyn <iestynjealous@ntlworld.com>
Date: Tue, 18 Oct 2016 22:07:20 +0100
Subject: [PATCH] Lua now errors if negative scales are used with v.drawScaled

---
 src/lua_hudlib.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c
index 7aadd9c0e..60cbbe501 100644
--- a/src/lua_hudlib.c
+++ b/src/lua_hudlib.c
@@ -369,6 +369,8 @@ static int libd_drawScaled(lua_State *L)
 	x = luaL_checkinteger(L, 1);
 	y = luaL_checkinteger(L, 2);
 	scale = luaL_checkinteger(L, 3);
+	if (scale < 0)
+		return luaL_error(L, "negative scale");
 	patch = *((patch_t **)luaL_checkudata(L, 4, META_PATCH));
 	flags = luaL_optinteger(L, 5, 0);
 	if (!lua_isnoneornil(L, 6))