diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lua/ltablib.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/lua/ltablib.c b/src/lua/ltablib.c index d344a47..d80eb80 100644 --- a/src/lua/ltablib.c +++ b/src/lua/ltablib.c | |||
| @@ -145,8 +145,8 @@ static int tmove (lua_State *L) { | |||
| 145 | 145 | ||
| 146 | static void addfield (lua_State *L, luaL_Buffer *b, lua_Integer i) { | 146 | static void addfield (lua_State *L, luaL_Buffer *b, lua_Integer i) { |
| 147 | lua_geti(L, 1, i); | 147 | lua_geti(L, 1, i); |
| 148 | if (!lua_isstring(L, -1)) | 148 | if (l_unlikely(!lua_isstring(L, -1))) |
| 149 | luaL_error(L, "invalid value (%s) at index %d in table for 'concat'", | 149 | luaL_error(L, "invalid value (%s) at index %I in table for 'concat'", |
| 150 | luaL_typename(L, -1), i); | 150 | luaL_typename(L, -1), i); |
| 151 | luaL_addvalue(b); | 151 | luaL_addvalue(b); |
| 152 | } | 152 | } |
| @@ -196,7 +196,8 @@ static int tunpack (lua_State *L) { | |||
| 196 | lua_Integer e = luaL_opt(L, luaL_checkinteger, 3, luaL_len(L, 1)); | 196 | lua_Integer e = luaL_opt(L, luaL_checkinteger, 3, luaL_len(L, 1)); |
| 197 | if (i > e) return 0; /* empty range */ | 197 | if (i > e) return 0; /* empty range */ |
| 198 | n = (lua_Unsigned)e - i; /* number of elements minus 1 (avoid overflows) */ | 198 | n = (lua_Unsigned)e - i; /* number of elements minus 1 (avoid overflows) */ |
| 199 | if (n >= (unsigned int)INT_MAX || !lua_checkstack(L, (int)(++n))) | 199 | if (l_unlikely(n >= (unsigned int)INT_MAX || |
| 200 | !lua_checkstack(L, (int)(++n)))) | ||
| 200 | return luaL_error(L, "too many results to unpack"); | 201 | return luaL_error(L, "too many results to unpack"); |
| 201 | for (; i < e; i++) { /* push arg[i..e - 1] (to avoid overflows) */ | 202 | for (; i < e; i++) { /* push arg[i..e - 1] (to avoid overflows) */ |
| 202 | lua_geti(L, 1, i); | 203 | lua_geti(L, 1, i); |
| @@ -300,14 +301,14 @@ static IdxT partition (lua_State *L, IdxT lo, IdxT up) { | |||
| 300 | for (;;) { | 301 | for (;;) { |
| 301 | /* next loop: repeat ++i while a[i] < P */ | 302 | /* next loop: repeat ++i while a[i] < P */ |
| 302 | while ((void)lua_geti(L, 1, ++i), sort_comp(L, -1, -2)) { | 303 | while ((void)lua_geti(L, 1, ++i), sort_comp(L, -1, -2)) { |
| 303 | if (i == up - 1) /* a[i] < P but a[up - 1] == P ?? */ | 304 | if (l_unlikely(i == up - 1)) /* a[i] < P but a[up - 1] == P ?? */ |
| 304 | luaL_error(L, "invalid order function for sorting"); | 305 | luaL_error(L, "invalid order function for sorting"); |
| 305 | lua_pop(L, 1); /* remove a[i] */ | 306 | lua_pop(L, 1); /* remove a[i] */ |
| 306 | } | 307 | } |
| 307 | /* after the loop, a[i] >= P and a[lo .. i - 1] < P */ | 308 | /* after the loop, a[i] >= P and a[lo .. i - 1] < P */ |
| 308 | /* next loop: repeat --j while P < a[j] */ | 309 | /* next loop: repeat --j while P < a[j] */ |
| 309 | while ((void)lua_geti(L, 1, --j), sort_comp(L, -3, -1)) { | 310 | while ((void)lua_geti(L, 1, --j), sort_comp(L, -3, -1)) { |
| 310 | if (j < i) /* j < i but a[j] > P ?? */ | 311 | if (l_unlikely(j < i)) /* j < i but a[j] > P ?? */ |
| 311 | luaL_error(L, "invalid order function for sorting"); | 312 | luaL_error(L, "invalid order function for sorting"); |
| 312 | lua_pop(L, 1); /* remove a[j] */ | 313 | lua_pop(L, 1); /* remove a[j] */ |
| 313 | } | 314 | } |
