Skip to content

Commit c030ba6

Browse files
committed
Remove the need for unwrap
Refactoring the `add_handle` method to avoid unwrapping an `Option`. Signed-off-by: Ionut Mihalcea <[email protected]>
1 parent e4cd231 commit c030ba6

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

tss-esapi/src/context/handle_manager.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ impl HandleManager {
4040
return Err(Error::local_error(WrapperErrorKind::InvalidParam));
4141
}
4242

43-
if self.open_handles.contains_key(&handle) {
44-
// It is safe to call unwrap because the existance of the key has already been verified.
45-
let stored_handle_drop_action = self.open_handles.get(&handle).unwrap();
43+
// The TSS might return the same handle, see #383
44+
if let Some(stored_handle_drop_action) = self.open_handles.get(&handle) {
4645
if handle_drop_action != *stored_handle_drop_action {
4746
error!("Handle drop action inconsistency");
4847
return Err(Error::local_error(WrapperErrorKind::InconsistentParams));

0 commit comments

Comments
 (0)