diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-04-12 11:48:24 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-04-12 11:48:24 -0300 |
commit | 2d3f09544895b422eeecf89e0d108da8b8fcdfca (patch) | |
tree | dcbb636cecf51d52945c1b0bd378f07781c5b987 /luaconf.h | |
parent | b0810c51c3f075cc8a309bfb3c1714ac42b0f020 (diff) | |
download | lua-2d3f09544895b422eeecf89e0d108da8b8fcdfca.tar.gz lua-2d3f09544895b422eeecf89e0d108da8b8fcdfca.tar.bz2 lua-2d3f09544895b422eeecf89e0d108da8b8fcdfca.zip |
Avoid using large buffers in 'string.format'
The result of "string.format("%.99f", -1e308) is 410 characters long,
but all other formats have much smaller limits (at most 99 plus a fex
extras). This commit avoids 'string.format' asking for a buffer
~400 chars large when ~100 will do.
Diffstat (limited to 'luaconf.h')
-rw-r--r-- | luaconf.h | 9 |
1 files changed, 1 insertions, 8 deletions
@@ -709,16 +709,9 @@ | |||
709 | 709 | ||
710 | /* | 710 | /* |
711 | @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. | 711 | @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. |
712 | ** CHANGE it if it uses too much C-stack space. (For long double, | ||
713 | ** 'string.format("%.99f", -1e4932)' needs 5052 bytes, so a | ||
714 | ** smaller buffer would force a memory allocation for each call to | ||
715 | ** 'string.format'.) | ||
716 | */ | 712 | */ |
717 | #if LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE | ||
718 | #define LUAL_BUFFERSIZE 8192 | ||
719 | #else | ||
720 | #define LUAL_BUFFERSIZE ((int)(16 * sizeof(void*) * sizeof(lua_Number))) | 713 | #define LUAL_BUFFERSIZE ((int)(16 * sizeof(void*) * sizeof(lua_Number))) |
721 | #endif | 714 | |
722 | 715 | ||
723 | /* | 716 | /* |
724 | @@ LUAI_MAXALIGN defines fields that, when used in a union, ensure | 717 | @@ LUAI_MAXALIGN defines fields that, when used in a union, ensure |