From 345daf2cc51341cf1be09626bdb9e7d2f81c1000 Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Sat, 24 Sep 2011 13:43:17 +0300 Subject: [PATCH] Panic if Lua runs out of memory This eliminates the most frequent class of Lua errors causing who knows what to happen. --- generic/lua.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/generic/lua.cpp b/generic/lua.cpp index ab682c8d..d228d7b4 100644 --- a/generic/lua.cpp +++ b/generic/lua.cpp @@ -169,9 +169,12 @@ namespace void* alloc(void* user, void* old, size_t olds, size_t news) { - if(news) - return realloc(old, news); - else + if(news) { + void* m = realloc(old, news); + if(!m) + OOM_panic(); + return m; + } else free(old); return NULL; }