diff --git a/lib/net/ldap/connection.rb b/lib/net/ldap/connection.rb index 1f900b6e..5315b31c 100644 --- a/lib/net/ldap/connection.rb +++ b/lib/net/ldap/connection.rb @@ -690,7 +690,7 @@ def delete(args) # # Typically a TCPSocket, but can be a OpenSSL::SSL::SSLSocket def socket - return @conn if defined? @conn + return @conn if defined?(@conn) && !@conn.nil? # First refactoring uses the existing methods open_connection and # prepare_socket to set @conn. Next cleanup would centralize connection