diff --git a/src/lua_mathlib.c b/src/lua_mathlib.c
index a55e3a0e4ed3ad510a170820f1204d389a3f0ded..d78cb23a49231ac130fb5338157c7db14747458e 100644
--- a/src/lua_mathlib.c
+++ b/src/lua_mathlib.c
@@ -32,13 +32,17 @@ static int lib_abs(lua_State *L)
 
 static int lib_min(lua_State *L)
 {
-	lua_pushinteger(L, min(luaL_checkinteger(L, 1), luaL_checkinteger(L, 2)));
+	int a = luaL_checkinteger(L, 1);
+	int b = luaL_checkinteger(L, 2);
+	lua_pushinteger(L, min(a,b));
 	return 1;
 }
 
 static int lib_max(lua_State *L)
 {
-	lua_pushinteger(L, max(luaL_checkinteger(L, 1), luaL_checkinteger(L, 2)));
+	int a = luaL_checkinteger(L, 1);
+	int b = luaL_checkinteger(L, 2);
+	lua_pushinteger(L, max(a,b));
 	return 1;
 }