mirror of
https://github.com/haproxy/haproxy.git
synced 2026-06-10 09:21:35 -04:00
BUG/MINOR: hlua: add check for lua_newstate
Calling lual_newstate(Init main lua stack) in the hlua_init_state() function, the return value of lua_newstate() may be NULL (for example in case of OOM). In this case, L will be NULL, and then crash happens in lua_getextraspace(). So, we add a check for lua_newstate. This should be backported at least to 2.4, maybe further.
This commit is contained in:
parent
c0456f45c8
commit
bfff46f411
1 changed files with 7 additions and 0 deletions
|
|
@ -13120,6 +13120,13 @@ lua_State *hlua_init_state(int thread_num)
|
|||
/* Init main lua stack. */
|
||||
L = lua_newstate(hlua_alloc, &hlua_global_allocator);
|
||||
|
||||
if (!L) {
|
||||
fprintf(stderr,
|
||||
"Lua init: critical error: lua_newstate() returned NULL."
|
||||
" This may possibly be caused by a memory allocation error.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Initialise Lua context to NULL */
|
||||
context = lua_getextraspace(L);
|
||||
*context = NULL;
|
||||
|
|
|
|||
Loading…
Reference in a new issue