diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-12-11 16:55:31 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-12-11 16:55:31 -0200 |
commit | 3cf340f676aea0d2f4a1135bf9aebc979f93d30a (patch) | |
tree | 56da5ea94cc0def597be495e6714d92f771b0164 | |
parent | 7ad20af2cf478c8ed900c1906f16ff73d4676851 (diff) | |
download | lua-3cf340f676aea0d2f4a1135bf9aebc979f93d30a.tar.gz lua-3cf340f676aea0d2f4a1135bf9aebc979f93d30a.tar.bz2 lua-3cf340f676aea0d2f4a1135bf9aebc979f93d30a.zip |
allows memory-allocation errors when shrinking blocks
-rw-r--r-- | ltests.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 2.234 2017/12/07 18:51:39 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 2.235 2017/12/08 15:19:13 roberto Exp roberto $ |
3 | ** Internal Module for Debugging of the Lua Implementation | 3 | ** Internal Module for Debugging of the Lua Implementation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -141,7 +141,7 @@ void *debug_realloc (void *ud, void *b, size_t oldsize, size_t size) { | |||
141 | freeblock(mc, block); | 141 | freeblock(mc, block); |
142 | return NULL; | 142 | return NULL; |
143 | } | 143 | } |
144 | if (mc->countlimit != ~0UL && size > oldsize) { /* count limit in use? */ | 144 | if (mc->countlimit != ~0UL && size > 0) { /* count limit in use? */ |
145 | if (mc->countlimit == 0) | 145 | if (mc->countlimit == 0) |
146 | return NULL; /* fake a memory allocation error */ | 146 | return NULL; /* fake a memory allocation error */ |
147 | mc->countlimit--; | 147 | mc->countlimit--; |
@@ -1001,6 +1001,7 @@ static int loadlib (lua_State *L) { | |||
1001 | {"math", luaopen_math}, | 1001 | {"math", luaopen_math}, |
1002 | {"string", luaopen_string}, | 1002 | {"string", luaopen_string}, |
1003 | {"table", luaopen_table}, | 1003 | {"table", luaopen_table}, |
1004 | {"T", luaB_opentests}, | ||
1004 | {NULL, NULL} | 1005 | {NULL, NULL} |
1005 | }; | 1006 | }; |
1006 | lua_State *L1 = getstate(L); | 1007 | lua_State *L1 = getstate(L); |