Skip to content

Commit 8910fd6

Browse files
committed
fix: Missing nil check for optional reply_tx
A previous refactor that made the "Unique Key" constructor fallible also added sending the error condition back over the optional reply tx channel argument, which is allowed to be nil. The nil check over this argument was omitted, though, which can lead to crashes in some situations.
1 parent 0fb0427 commit 8910fd6

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

drivers/SmartThings/sonos/src/api/sonos_connection.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ local _update_subscriptions_helper = function(
7878
local unique_key, bad_key_part = utils.sonos_unique_key(householdId, playerId)
7979
if not unique_key then
8080
local err_msg = string.format("Invalid Sonos Unique Key Part: %s", bad_key_part)
81-
reply_tx:send(table.pack(nil, err_msg))
81+
if reply_tx then
82+
reply_tx:send(table.pack(nil, err_msg))
83+
else
84+
log.warn(string.format("Update Subscriptions Error: %s", err_msg))
85+
end
8286
return
8387
end
8488
Router.send_message_to_player(unique_key, payload, reply_tx)

0 commit comments

Comments
 (0)