Panic if Lua runs out of memory
This eliminates the most frequent class of Lua errors causing who knows what to happen.
This commit is contained in:
parent
fb5d773339
commit
345daf2cc5
1 changed files with 6 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue