Gracefully handle broken custom allocator.
Reported by Alex Orlenko. #1393
This commit is contained in:
@@ -261,7 +261,11 @@ LUA_API lua_State *lua_newstate(lua_Alloc allocf, void *allocd)
|
||||
}
|
||||
#endif
|
||||
GG = (GG_State *)allocf(allocd, NULL, 0, sizeof(GG_State));
|
||||
if (GG == NULL || !checkptrGC(GG)) return NULL;
|
||||
if (GG == NULL) return NULL;
|
||||
if (!checkptrGC(GG)) {
|
||||
allocf(allocd, GG, sizeof(GG_State), 0);
|
||||
return NULL;
|
||||
}
|
||||
memset(GG, 0, sizeof(GG_State));
|
||||
L = &GG->L;
|
||||
g = &GG->g;
|
||||
|
||||
Reference in New Issue
Block a user