Skip to content

Commit a90842b

Browse files
committed
Prevent Null exception when closing socket.
1 parent 67bdfd1 commit a90842b

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

WinNUT_V2/WinNUT-Client_Common/Nut_Socket.vb

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,17 +375,33 @@ Public Class Nut_Socket
375375
Me.ConnectionStatus = True
376376
End If
377377
End Sub
378+
378379
Private Sub Close_Socket()
379380
Try
380-
Me.WriterStream.Close()
381-
Me.ReaderStream.Close()
382-
Me.NutStream.Close()
383-
Me.NutTCP.Close()
384-
Me.NutSocket.Close()
381+
If WriterStream IsNot Nothing Then
382+
WriterStream.Close()
383+
End If
384+
385+
If ReaderStream IsNot Nothing Then
386+
ReaderStream.Close()
387+
End If
388+
389+
If NutStream IsNot Nothing Then
390+
NutStream.Close()
391+
End If
392+
393+
If NutTCP IsNot Nothing Then
394+
NutTCP.Close()
395+
End If
396+
397+
If NutSocket IsNot Nothing Then
398+
NutSocket.Close()
399+
End If
385400
Catch Excep As Exception
386401
End Try
387402
Me.ConnectionStatus = False
388403
End Sub
404+
389405
Public Sub Disconnect(Optional ByVal ForceDisconnect = False)
390406
Query_Data("LOGOUT")
391407
Close_Socket()

0 commit comments

Comments
 (0)