summaryrefslogtreecommitdiff
path: root/libs/liblua/src/lmem.c
diff options
context:
space:
mode:
Diffstat (limited to 'libs/liblua/src/lmem.c')
-rw-r--r--libs/liblua/src/lmem.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/libs/liblua/src/lmem.c b/libs/liblua/src/lmem.c
index 4feaf036c7..0a0476cc77 100644
--- a/libs/liblua/src/lmem.c
+++ b/libs/liblua/src/lmem.c
@@ -1,5 +1,5 @@
/*
-** $Id: lmem.c,v 1.89 2014/11/02 19:33:33 roberto Exp $
+** $Id: lmem.c,v 1.91 2015/03/06 19:45:54 roberto Exp $
** Interface to Memory Manager
** See Copyright Notice in lua.h
*/
@@ -85,10 +85,11 @@ void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) {
#endif
newblock = (*g->frealloc)(g->ud, block, osize, nsize);
if (newblock == NULL && nsize > 0) {
- api_check( nsize > realosize,
- "realloc cannot fail when shrinking a block");
- luaC_fullgc(L, 1); /* try to free some memory... */
- newblock = (*g->frealloc)(g->ud, block, osize, nsize); /* try again */
+ lua_assert(nsize > realosize); /* cannot fail when shrinking a block */
+ if (g->version) { /* is state fully built? */
+ luaC_fullgc(L, 1); /* try to free some memory... */
+ newblock = (*g->frealloc)(g->ud, block, osize, nsize); /* try again */
+ }
if (newblock == NULL)
luaD_throw(L, LUA_ERRMEM);
}