From c5ebed73997c118306e548ac5ccb98302dbf90e4 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 11 Dec 2017 10:27:48 -0200 Subject: 'luaM_shrinkvector' raises an error if it cannot shrink the block (several parts of Lua use array size in protos as proxies for number of valid elements) --- lmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lmem.c b/lmem.c index afacbb9f..ecafef49 100644 --- a/lmem.c +++ b/lmem.c @@ -1,5 +1,5 @@ /* -** $Id: lmem.c,v 1.93 2017/12/07 18:59:52 roberto Exp roberto $ +** $Id: lmem.c,v 1.94 2017/12/08 17:28:25 roberto Exp roberto $ ** Interface to Memory Manager ** See Copyright Notice in lua.h */ @@ -89,7 +89,7 @@ void *luaM_shrinkvector_ (lua_State *L, void *block, int *size, lua_assert(newsize <= oldsize); newblock = (*g->frealloc)(g->ud, block, oldsize, newsize); if (newblock == NULL && final_n > 0) /* allocation failed? */ - return block; /* keep old block */ + luaM_error(L); else { g->GCdebt += newsize - oldsize; *size = final_n; -- cgit v1.2.3-55-g6feb