File tree Expand file tree Collapse file tree 1 file changed +12
-11
lines changed
Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -119,7 +119,8 @@ impl COMPort {
119119 pub fn try_clone_native ( & self ) -> Result < COMPort > {
120120 let process_handle: HANDLE = unsafe { GetCurrentProcess ( ) } ;
121121 let mut cloned_handle: HANDLE = INVALID_HANDLE_VALUE ;
122- unsafe {
122+
123+ let duplicated = unsafe {
123124 DuplicateHandle (
124125 process_handle,
125126 self . raw_handle ( ) ,
@@ -128,16 +129,16 @@ impl COMPort {
128129 0 ,
129130 TRUE ,
130131 DUPLICATE_SAME_ACCESS ,
131- ) ;
132- if cloned_handle != INVALID_HANDLE_VALUE {
133- Ok ( COMPort {
134- handle : OwnedHandle :: from_raw_handle ( cloned_handle ) ,
135- port_name : self . port_name . clone ( ) ,
136- timeout : self . timeout ,
137- } )
138- } else {
139- Err ( super :: error :: last_os_error ( ) )
140- }
132+ )
133+ } ;
134+ if duplicated == TRUE && cloned_handle != INVALID_HANDLE_VALUE {
135+ Ok ( COMPort {
136+ handle : unsafe { OwnedHandle :: from_raw_handle ( cloned_handle ) } ,
137+ port_name : self . port_name . clone ( ) ,
138+ timeout : self . timeout ,
139+ } )
140+ } else {
141+ Err ( super :: error :: last_os_error ( ) )
141142 }
142143 }
143144
You can’t perform that action at this time.
0 commit comments