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) { | |||
1185 | struct ex_state *state; | 1185 | struct ex_state *state; |
1186 | struct lua_State *thr; | 1186 | struct lua_State *thr; |
1187 | 1187 | ||
1188 | lua_pushlightuserdata(L, (void *)&ex__gc); | ||
1189 | lua_gettable(L, LUA_REGISTRYINDEX); | ||
1190 | |||
1191 | if (!lua_isnil(L, -1)) { | ||
1192 | lua_pop(L, 1); | ||
1193 | |||
1194 | return; | ||
1195 | } | ||
1196 | |||
1188 | state = prepudata(L, sizeof *state, NULL, &ex__gc); | 1197 | state = prepudata(L, sizeof *state, NULL, &ex__gc); |
1189 | LIST_INIT(&state->data); | 1198 | LIST_INIT(&state->data); |
1190 | 1199 | ||