aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-12-11 16:55:31 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-12-11 16:55:31 -0200
commit3cf340f676aea0d2f4a1135bf9aebc979f93d30a (patch)
tree56da5ea94cc0def597be495e6714d92f771b0164
parent7ad20af2cf478c8ed900c1906f16ff73d4676851 (diff)
downloadlua-3cf340f676aea0d2f4a1135bf9aebc979f93d30a.tar.gz
lua-3cf340f676aea0d2f4a1135bf9aebc979f93d30a.tar.bz2
lua-3cf340f676aea0d2f4a1135bf9aebc979f93d30a.zip
allows memory-allocation errors when shrinking blocks
-rw-r--r--ltests.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/ltests.c b/ltests.c
index 88333528..3e9c82a0 100644
--- a/ltests.c
+++ b/ltests.c
@@ -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);