aboutsummaryrefslogtreecommitdiff
path: root/src/universe.c
diff options
context:
space:
mode:
authorBenoit Germain <bnt.germain@gmail.com>2018-11-07 08:19:46 +0100
committerBenoit Germain <bnt.germain@gmail.com>2018-11-07 08:19:46 +0100
commitc57bc44324a767407d1eb9f95e3c7589700f042e (patch)
treead0fd1c15a31157c1ba4532840aa41decb04f124 /src/universe.c
parentef8fc2c4a215110b034424f9c423111d34963f31 (diff)
downloadlanes-c57bc44324a767407d1eb9f95e3c7589700f042e.tar.gz
lanes-c57bc44324a767407d1eb9f95e3c7589700f042e.tar.bz2
lanes-c57bc44324a767407d1eb9f95e3c7589700f042e.zip
Fix potential crash at application shutdown when deep userdata were created before Lanes is required
Diffstat (limited to 'src/universe.c')
-rw-r--r--src/universe.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/universe.c b/src/universe.c
index 00de1f3..4689a09 100644
--- a/src/universe.c
+++ b/src/universe.c
@@ -56,7 +56,14 @@ void universe_store( lua_State* L, Universe* U)
56{ 56{
57 STACK_CHECK( L); 57 STACK_CHECK( L);
58 push_unique_key( L, UNIVERSE_REGKEY); 58 push_unique_key( L, UNIVERSE_REGKEY);
59 lua_pushlightuserdata( L, U); 59 if( NULL != U)
60 {
61 lua_pushlightuserdata( L, U);
62 }
63 else
64 {
65 lua_pushnil( L);
66 }
60 lua_rawset( L, LUA_REGISTRYINDEX); 67 lua_rawset( L, LUA_REGISTRYINDEX);
61 STACK_END( L, 0); 68 STACK_END( L, 0);
62} 69}