Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions crates/miden-tx/src/host/link_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,9 @@ impl<'process> LinkMap<'process> {
if head_ptr == ZERO {
None
} else {
Some(
u32::try_from(head_ptr.as_canonical_u64())
.expect("head ptr should be a valid ptr"),
)
// Be tolerant to potential malformed pointers: return None instead of panicking
// if the value cannot fit into a u32.
u32::try_from(head_ptr.as_canonical_u64()).ok()
Comment on lines +98 to +100
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the pointer is malformed, it would mean that there is a serious bug in the transaction kernel and we should definitely either panic or return an error. So, returning None is probably not a good idea.

}
})
}
Expand Down