Ensure port handle exists before closing it

This commit is contained in:
Will Hedgecock 2021-11-17 01:07:24 -06:00
parent 79d09f38c9
commit 20ea873390
1 changed files with 2 additions and 1 deletions

View File

@ -506,7 +506,8 @@ public final class SerialPort
{
if (serialEventListener != null)
serialEventListener.stopListening();
portHandle = closePortNative(portHandle);
if (portHandle > 0)
portHandle = closePortNative(portHandle);
return (portHandle < 0);
}