diff options
| -rw-r--r-- | ldo.c | 14 | ||||
| -rw-r--r-- | ltests.h | 1 | ||||
| -rw-r--r-- | lua.h | 6 | ||||
| -rw-r--r-- | luaconf.h | 14 |
4 files changed, 17 insertions, 18 deletions
| @@ -174,6 +174,20 @@ TStatus luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { | |||
| 174 | #define STACKERRSPACE 200 | 174 | #define STACKERRSPACE 200 |
| 175 | 175 | ||
| 176 | 176 | ||
| 177 | /* | ||
| 178 | ** LUAI_MAXSTACK limits the size of the Lua stack. | ||
| 179 | ** It must fit into INT_MAX/2. | ||
| 180 | */ | ||
| 181 | |||
| 182 | #if !defined(LUAI_MAXSTACK) | ||
| 183 | #if 1000000 < (INT_MAX / 2) | ||
| 184 | #define LUAI_MAXSTACK 1000000 | ||
| 185 | #else | ||
| 186 | #define LUAI_MAXSTACK (INT_MAX / 2u) | ||
| 187 | #endif | ||
| 188 | #endif | ||
| 189 | |||
| 190 | |||
| 177 | /* maximum stack size that respects size_t */ | 191 | /* maximum stack size that respects size_t */ |
| 178 | #define MAXSTACK_BYSIZET ((MAX_SIZET / sizeof(StackValue)) - STACKERRSPACE) | 192 | #define MAXSTACK_BYSIZET ((MAX_SIZET / sizeof(StackValue)) - STACKERRSPACE) |
| 179 | 193 | ||
| @@ -155,7 +155,6 @@ LUA_API void *debug_realloc (void *ud, void *block, | |||
| 155 | ** Reduce maximum stack size to make stack-overflow tests run faster. | 155 | ** Reduce maximum stack size to make stack-overflow tests run faster. |
| 156 | ** (But value is still large enough to overflow smaller integers.) | 156 | ** (But value is still large enough to overflow smaller integers.) |
| 157 | */ | 157 | */ |
| 158 | #undef LUAI_MAXSTACK | ||
| 159 | #define LUAI_MAXSTACK 68000 | 158 | #define LUAI_MAXSTACK 68000 |
| 160 | 159 | ||
| 161 | 160 | ||
| @@ -37,10 +37,10 @@ | |||
| 37 | 37 | ||
| 38 | /* | 38 | /* |
| 39 | ** Pseudo-indices | 39 | ** Pseudo-indices |
| 40 | ** (-LUAI_MAXSTACK is the minimum valid index; we keep some free empty | 40 | ** (The stack size is limited to INT_MAX/2; we keep some free empty |
| 41 | ** space after that to help overflow detection) | 41 | ** space after that to help overflow detection.) |
| 42 | */ | 42 | */ |
| 43 | #define LUA_REGISTRYINDEX (-LUAI_MAXSTACK - 1000) | 43 | #define LUA_REGISTRYINDEX (-(INT_MAX/2 + 1000)) |
| 44 | #define lua_upvalueindex(i) (LUA_REGISTRYINDEX - (i)) | 44 | #define lua_upvalueindex(i) (LUA_REGISTRYINDEX - (i)) |
| 45 | 45 | ||
| 46 | 46 | ||
| @@ -764,20 +764,6 @@ | |||
| 764 | */ | 764 | */ |
| 765 | 765 | ||
| 766 | /* | 766 | /* |
| 767 | @@ LUAI_MAXSTACK limits the size of the Lua stack. | ||
| 768 | ** CHANGE it if you need a different limit. This limit is arbitrary; | ||
| 769 | ** its only purpose is to stop Lua from consuming unlimited stack | ||
| 770 | ** space and to reserve some numbers for pseudo-indices. | ||
| 771 | ** (It must fit into max(int)/2.) | ||
| 772 | */ | ||
| 773 | #if 1000000 < (INT_MAX / 2) | ||
| 774 | #define LUAI_MAXSTACK 1000000 | ||
| 775 | #else | ||
| 776 | #define LUAI_MAXSTACK (INT_MAX / 2u) | ||
| 777 | #endif | ||
| 778 | |||
| 779 | |||
| 780 | /* | ||
| 781 | @@ LUA_EXTRASPACE defines the size of a raw memory area associated with | 767 | @@ LUA_EXTRASPACE defines the size of a raw memory area associated with |
| 782 | ** a Lua state with very fast access. | 768 | ** a Lua state with very fast access. |
| 783 | ** CHANGE it if you need a different size. | 769 | ** CHANGE it if you need a different size. |
