summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwilliam <william@25tandclement.com>2015-07-25 14:37:04 -0700
committerwilliam <william@25tandclement.com>2015-07-25 14:37:04 -0700
commitfdaaf522474df9dd9eb23e875acd939cd0d2ea90 (patch)
tree5746aba088ab30cb4be6fbdc0b0bd9893e897770
parentf73eccfc8e589e6cc670c488b78715ee40b6985d (diff)
downloadluaossl-fdaaf522474df9dd9eb23e875acd939cd0d2ea90.tar.gz
luaossl-fdaaf522474df9dd9eb23e875acd939cd0d2ea90.tar.bz2
luaossl-fdaaf522474df9dd9eb23e875acd939cd0d2ea90.zip
refactor ex_newstate fix, which left nil on the stack
-rw-r--r--src/openssl.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/openssl.c b/src/openssl.c
index 8977234..9dbcda7 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -1181,18 +1181,23 @@ static int ex__gc(lua_State *L) {
1181 return 0; 1181 return 0;
1182} /* ex__gc() */ 1182} /* ex__gc() */
1183 1183
1184static void ex_newstate(lua_State *L) { 1184static _Bool ex_hasstate(lua_State *L) {
1185 struct ex_state *state; 1185 _Bool has;
1186 struct lua_State *thr;
1187 1186
1188 lua_pushlightuserdata(L, (void *)&ex__gc); 1187 lua_pushlightuserdata(L, (void *)&ex__gc);
1189 lua_gettable(L, LUA_REGISTRYINDEX); 1188 lua_gettable(L, LUA_REGISTRYINDEX);
1189 has = !lua_isnil(L, -1);
1190 lua_pop(L, 1);
1190 1191
1191 if (!lua_isnil(L, -1)) { 1192 return has;
1192 lua_pop(L, 1); 1193} /* ex_hasstate() */
1193 1194
1195static void ex_newstate(lua_State *L) {
1196 struct ex_state *state;
1197 struct lua_State *thr;
1198
1199 if (ex_hasstate(L))
1194 return; 1200 return;
1195 }
1196 1201
1197 state = prepudata(L, sizeof *state, NULL, &ex__gc); 1202 state = prepudata(L, sizeof *state, NULL, &ex__gc);
1198 LIST_INIT(&state->data); 1203 LIST_INIT(&state->data);