aboutsummaryrefslogtreecommitdiff
path: root/libraries/lua-md5/3ee1414.patch
blob: 91dd4a13b6b210d91798ae1d5f2372400ca4f1fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
commit 3ee141422f30f45d841bb21be90474dd1fb68a67
Author: Tomas Guisasola <tomasguisasola@gmail.com>
Date:   Mon Sep 23 11:26:01 2013 -0300

    Bug correction on upvalues management (thanks to Philipp Janda).

diff --git a/src/compat-5.2.c b/src/compat-5.2.c
index f54caa2..ce57660 100644
--- a/src/compat-5.2.c
+++ b/src/compat-5.2.c
@@ -12,9 +12,9 @@ void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
     int i;
     lua_pushstring(L, l->name);
     for (i = 0; i < nup; i++)  /* copy upvalues to the top */
-      lua_pushvalue(L, -nup);
+      lua_pushvalue(L, -(nup + 1));
     lua_pushcclosure(L, l->func, nup);  /* closure with those upvalues */
-    lua_settable(L, -3);
+    lua_settable(L, -(nup + 3)); /* table must be below the upvalues, the name and the closure */
   }
   lua_pop(L, nup);  /* remove upvalues */
 }