diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-06-17 18:16:46 +0200 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-06-17 18:16:46 +0200 |
commit | 54b47307ce4b2e21bc12c1602c77fecf55380452 (patch) | |
tree | 9e807499e9bde6ba7193e98d5f611b2d66173490 /src/state.cpp | |
parent | ca46cc7883b7b2749307a3e5a8196368fb52ba09 (diff) | |
download | lanes-54b47307ce4b2e21bc12c1602c77fecf55380452.tar.gz lanes-54b47307ce4b2e21bc12c1602c77fecf55380452.tar.bz2 lanes-54b47307ce4b2e21bc12c1602c77fecf55380452.zip |
Foolproofed config.allocator when it is a function
Diffstat (limited to 'src/state.cpp')
-rw-r--r-- | src/state.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/state.cpp b/src/state.cpp index 3f6b3d7..ee0b199 100644 --- a/src/state.cpp +++ b/src/state.cpp | |||
@@ -208,6 +208,9 @@ namespace state { | |||
208 | lua_pushcclosure(from, U->provideAllocator, 0); | 208 | lua_pushcclosure(from, U->provideAllocator, 0); |
209 | lua_call(from, 0, 1); | 209 | lua_call(from, 0, 1); |
210 | AllocatorDefinition* const _def{ luaG_tofulluserdata<AllocatorDefinition>(from, -1) }; | 210 | AllocatorDefinition* const _def{ luaG_tofulluserdata<AllocatorDefinition>(from, -1) }; |
211 | if (!_def || _def->version != AllocatorDefinition::kAllocatorVersion) { | ||
212 | raise_luaL_error(from, "Bad config.allocator function, must provide a valid AllocatorDefinition"); | ||
213 | } | ||
211 | lua_State* const _L{ lua_newstate(_def->allocF, _def->allocUD) }; | 214 | lua_State* const _L{ lua_newstate(_def->allocF, _def->allocUD) }; |
212 | lua_pop(from, 1); | 215 | lua_pop(from, 1); |
213 | return _L; | 216 | return _L; |