Commit 096164a7 authored by serg3295's avatar serg3295 Committed by J Mattsson
Browse files

fix(mqtt): adds parameter checking to nil

parent 9a9548b0
...@@ -368,14 +368,19 @@ static int mqtt_connect(lua_State* L) { ...@@ -368,14 +368,19 @@ static int mqtt_connect(lua_State* L) {
if (is_mqtt_uri || is_mqtts_uri) if (is_mqtt_uri || is_mqtts_uri)
return luaL_error(L, "port arg must be nil if giving full uri"); return luaL_error(L, "port arg must be nil if giving full uri");
port = luaL_checknumber(L, n); port = luaL_checknumber(L, n);
n++;
} else if (lua_type(L, n) == LUA_TNIL) {
n++;
} }
n++;
if (lua_isnumber(L, n)) { if (lua_isnumber(L, n)) {
if (is_mqtt_uri || is_mqtts_uri) if (is_mqtt_uri || is_mqtts_uri)
return luaL_error(L, "secure on/off determined by uri"); return luaL_error(L, "secure on/off determined by uri");
secure = !!luaL_checkinteger(L, n); secure = !!luaL_checkinteger(L, n);
n++;
} else if (lua_type(L, n) == LUA_TNIL) {
n++;
} else { } else {
if (lua_istable(L, n)) { if (lua_istable(L, n)) {
secure = true; secure = true;
...@@ -396,9 +401,10 @@ static int mqtt_connect(lua_State* L) { ...@@ -396,9 +401,10 @@ static int mqtt_connect(lua_State* L) {
luaX_set_ref(L, -1, &mqtt_context->client_key_pem); luaX_set_ref(L, -1, &mqtt_context->client_key_pem);
} }
lua_pop(L, 1); lua_pop(L, 1);
//
n++;
} }
} }
n++;
if (lua_isnumber(L, n)) { if (lua_isnumber(L, n)) {
reconnect = !!luaL_checkinteger(L, n); reconnect = !!luaL_checkinteger(L, n);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment