diff options
author | William Ahern <william+macosx@25thandclement.com> | 2015-07-24 20:14:06 -0700 |
---|---|---|
committer | William Ahern <william+macosx@25thandclement.com> | 2015-07-24 20:14:06 -0700 |
commit | f73eccfc8e589e6cc670c488b78715ee40b6985d (patch) | |
tree | a0defbca753978a2df3fa936d73cfca6e5471ed6 | |
parent | f04c43ef5ab676b8c6b7468b47a278aca47bd0f7 (diff) | |
download | luaossl-f73eccfc8e589e6cc670c488b78715ee40b6985d.tar.gz luaossl-f73eccfc8e589e6cc670c488b78715ee40b6985d.tar.bz2 luaossl-f73eccfc8e589e6cc670c488b78715ee40b6985d.zip |
Don't recreate an exdata state singleton object when one already exists, otherwise we wrongly invalidate any data already installed. Because ex_newstate is invoked from every submodule, this can easily happen if code loads one submodule, attaches some data to a new OpenSSL object, then loads some other submodule for the first time.
-rw-r--r-- | src/openssl.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/openssl.c b/src/openssl.c index 7b2ce89..8977234 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -1185,6 +1185,15 @@ static void ex_newstate(lua_State *L) { struct ex_state *state; struct lua_State *thr; + lua_pushlightuserdata(L, (void *)&ex__gc); + lua_gettable(L, LUA_REGISTRYINDEX); + + if (!lua_isnil(L, -1)) { + lua_pop(L, 1); + + return; + } + state = prepudata(L, sizeof *state, NULL, &ex__gc); LIST_INIT(&state->data); |