aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2010-11-19 18:44:59 +0100
committerMike Pall <mike>2010-11-19 18:44:59 +0100
commitb776bf91ff9c32a15958642967a9e7ed309be06e (patch)
treee6078543d2db44b24484509ad15cb3acb2705661 /src
parent52fd87bf348715c13b469fd32b2b56d3bfe1d1f9 (diff)
downloadluajit-b776bf91ff9c32a15958642967a9e7ed309be06e.tar.gz
luajit-b776bf91ff9c32a15958642967a9e7ed309be06e.tar.bz2
luajit-b776bf91ff9c32a15958642967a9e7ed309be06e.zip
Tighter check on table.sort function compliance (from Lua 5.2).
Diffstat (limited to 'src')
-rw-r--r--src/lib_table.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib_table.c b/src/lib_table.c
index 5a1e0f78..cf39f08c 100644
--- a/src/lib_table.c
+++ b/src/lib_table.c
@@ -225,12 +225,12 @@ static void auxsort(lua_State *L, int l, int u)
225 for (;;) { /* invariant: a[l..i] <= P <= a[j..u] */ 225 for (;;) { /* invariant: a[l..i] <= P <= a[j..u] */
226 /* repeat ++i until a[i] >= P */ 226 /* repeat ++i until a[i] >= P */
227 while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) { 227 while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) {
228 if (i>u) lj_err_caller(L, LJ_ERR_TABSORT); 228 if (i>=u) lj_err_caller(L, LJ_ERR_TABSORT);
229 lua_pop(L, 1); /* remove a[i] */ 229 lua_pop(L, 1); /* remove a[i] */
230 } 230 }
231 /* repeat --j until a[j] <= P */ 231 /* repeat --j until a[j] <= P */
232 while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) { 232 while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) {
233 if (j<l) lj_err_caller(L, LJ_ERR_TABSORT); 233 if (j<=l) lj_err_caller(L, LJ_ERR_TABSORT);
234 lua_pop(L, 1); /* remove a[j] */ 234 lua_pop(L, 1); /* remove a[j] */
235 } 235 }
236 if (j<i) { 236 if (j<i) {