diff options
author | Li Jin <dragon-fly@qq.com> | 2022-09-30 11:29:41 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2022-09-30 11:29:41 +0800 |
commit | 5aa41b436b3fdf29f5a0046c68cb60b16fa09eb2 (patch) | |
tree | 5c5c0ecdab0d19544652bc05b70d8131e1645337 /src/3rdParty/lua/lauxlib.c | |
parent | a6b6753fda9745f316f3236462b74794b35b85c9 (diff) | |
download | yuescript-5aa41b436b3fdf29f5a0046c68cb60b16fa09eb2.tar.gz yuescript-5aa41b436b3fdf29f5a0046c68cb60b16fa09eb2.tar.bz2 yuescript-5aa41b436b3fdf29f5a0046c68cb60b16fa09eb2.zip |
fix issue #81, refactor continue with gotos.
Diffstat (limited to 'src/3rdParty/lua/lauxlib.c')
-rw-r--r-- | src/3rdParty/lua/lauxlib.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/3rdParty/lua/lauxlib.c b/src/3rdParty/lua/lauxlib.c index cba5df9..4ca6c65 100644 --- a/src/3rdParty/lua/lauxlib.c +++ b/src/3rdParty/lua/lauxlib.c | |||
@@ -526,14 +526,14 @@ static void newbox (lua_State *L) { | |||
526 | 526 | ||
527 | /* | 527 | /* |
528 | ** Compute new size for buffer 'B', enough to accommodate extra 'sz' | 528 | ** Compute new size for buffer 'B', enough to accommodate extra 'sz' |
529 | ** bytes. (The test for "double is not big enough" also gets the | 529 | ** bytes. (The test for "not big enough" also gets the case when the |
530 | ** case when the multiplication by 2 overflows.) | 530 | ** computation of 'newsize' overflows.) |
531 | */ | 531 | */ |
532 | static size_t newbuffsize (luaL_Buffer *B, size_t sz) { | 532 | static size_t newbuffsize (luaL_Buffer *B, size_t sz) { |
533 | size_t newsize = B->size * 2; /* double buffer size */ | 533 | size_t newsize = (B->size / 2) * 3; /* buffer size * 1.5 */ |
534 | if (l_unlikely(MAX_SIZET - sz < B->n)) /* overflow in (B->n + sz)? */ | 534 | if (l_unlikely(MAX_SIZET - sz < B->n)) /* overflow in (B->n + sz)? */ |
535 | return luaL_error(B->L, "buffer too large"); | 535 | return luaL_error(B->L, "buffer too large"); |
536 | if (newsize < B->n + sz) /* double is not big enough? */ | 536 | if (newsize < B->n + sz) /* not big enough? */ |
537 | newsize = B->n + sz; | 537 | newsize = B->n + sz; |
538 | return newsize; | 538 | return newsize; |
539 | } | 539 | } |