Skip to content

Commit c896344

Browse files
SerialImp.c:RXTXPort(open) - on failure release file descriptor and lock
1 parent b1da316 commit c896344

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/c/src/SerialImp.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,11 +734,16 @@ JNIEXPORT jint JNICALL RXTXPort(open)(
734734
report_error( message );
735735

736736
close(fd);
737+
UNLOCK(filename, pid);
737738
goto fail;
738739
}
739740
#endif /* OPEN_EXCL */
740741

741-
if( configure_port( fd ) ) goto fail;
742+
if( configure_port( fd ) ) {
743+
close(fd);
744+
UNLOCK(filename, pid);
745+
goto fail;
746+
}
742747
(*env)->ReleaseStringUTFChars( env, jstr, filename );
743748
snprintf( message, sizeof(message), "open: fd returned is %i\n", fd );
744749
report( message );

0 commit comments

Comments
 (0)