Skip to content

Commit 00ee933

Browse files
committed
Fixes crash calling setSecure on a socket not yet connected.
Calling setSecure on a socket that isn't connected yet causes a nasty crash. This commit adds a check and issues a Lua error instead. fixes #16
1 parent bbd36c8 commit 00ee933

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/luanode/net.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,12 @@ end
392392

393393

394394
function Socket:setSecure(context)
395+
396+
-- We need a socket here in order to make it secure
397+
if not self._raw_socket then
398+
error("Socket is closed.")
399+
end
400+
395401
-- Do we have openssl crypto?
396402
local SecureContext = process.SecureContext
397403
--local SecureStream = process.SecureStream

0 commit comments

Comments
 (0)