Skip to content

Commit

Permalink
fix(mqtt): adds parameter checking to nil
Browse files Browse the repository at this point in the history
  • Loading branch information
serg3295 authored and jmattsson committed Jul 19, 2023
1 parent 3b850eb commit 0415e2c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions components/modules/mqtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,14 +368,19 @@ static int mqtt_connect(lua_State* L) {
if (is_mqtt_uri || is_mqtts_uri)
return luaL_error(L, "port arg must be nil if giving full uri");
port = luaL_checknumber(L, n);
n++;
} else if (lua_type(L, n) == LUA_TNIL) {
n++;
}
n++;

if (lua_isnumber(L, n)) {
if (is_mqtt_uri || is_mqtts_uri)
return luaL_error(L, "secure on/off determined by uri");
secure = !!luaL_checkinteger(L, n);
n++;

} else if (lua_type(L, n) == LUA_TNIL) {
n++;
} else {
if (lua_istable(L, n)) {
secure = true;
Expand All @@ -396,9 +401,10 @@ static int mqtt_connect(lua_State* L) {
luaX_set_ref(L, -1, &mqtt_context->client_key_pem);
}
lua_pop(L, 1);
//
n++;
}
}
n++;

if (lua_isnumber(L, n)) {
reconnect = !!luaL_checkinteger(L, n);
Expand Down

0 comments on commit 0415e2c

Please sign in to comment.