From 91a9c0cf722a9a536b58a0a5afd7af7aa8298943 Mon Sep 17 00:00:00 2001 From: Will Hedgecock Date: Tue, 18 Jan 2022 13:25:17 -0600 Subject: [PATCH] Ensure port handle is valid before reconfiguring timeouts --- src/main/java/com/fazecast/jSerialComm/SerialPort.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/fazecast/jSerialComm/SerialPort.java b/src/main/java/com/fazecast/jSerialComm/SerialPort.java index c5ee398..2fa1fab 100644 --- a/src/main/java/com/fazecast/jSerialComm/SerialPort.java +++ b/src/main/java/com/fazecast/jSerialComm/SerialPort.java @@ -1017,7 +1017,8 @@ public final class SerialPort { serialEventListener.stopListening(); serialEventListener = null; - configTimeouts(portHandle, timeoutMode, readTimeout, writeTimeout, eventFlags); + if (portHandle != 0) + configTimeouts(portHandle, timeoutMode, readTimeout, writeTimeout, eventFlags); } userDataListener = null; }