File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -497,6 +497,10 @@ impl TryFrom<HandleOrInvalid> for OwnedHandle {
497
497
fn try_from ( handle_or_invalid : HandleOrInvalid ) -> Result < Self , ( ) > {
498
498
let raw = handle_or_invalid. 0 ;
499
499
if raw == INVALID_HANDLE_VALUE {
500
+ // Don't call `CloseHandle`; it'd be harmless, except that it could
501
+ // overwrite the `GetLastError` error.
502
+ forget ( handle_or_invalid) ;
503
+
500
504
Err ( ( ) )
501
505
} else {
502
506
Ok ( OwnedHandle { handle : raw } )
@@ -512,6 +516,10 @@ impl TryFrom<HandleOrNull> for OwnedHandle {
512
516
fn try_from ( handle_or_null : HandleOrNull ) -> Result < Self , ( ) > {
513
517
let raw = handle_or_null. 0 ;
514
518
if raw. is_null ( ) {
519
+ // Don't call `CloseHandle`; it'd be harmless, except that it could
520
+ // overwrite the `GetLastError` error.
521
+ forget ( handle_or_null) ;
522
+
515
523
Err ( ( ) )
516
524
} else {
517
525
Ok ( OwnedHandle { handle : raw } )
You can’t perform that action at this time.
0 commit comments