Skip to content

Commit 01925f7

Browse files
committed
Improve comments
1 parent 15cf875 commit 01925f7

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

Cargo.lock

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bitwarden-crypto/src/store/backend/implementation/custom_alloc/linux_memfd_secret.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ unsafe impl Allocator for LinuxMemfdSecretAlloc {
5555
return Err(AllocError);
5656
};
5757

58-
// Check that the pointer is aligned to the requested alignment.
59-
// This should never happen, but just in case, we free the memory and return an allocation
60-
// error.
58+
// The pointer that we return needs to be aligned to the requested alignment.
59+
// If that's not the case, we should free the memory and return an allocation error.
60+
// While we check for this error condition, this should never happen in practice, as the
61+
// pointer returned by `memfd_secret_sized` should be page-aligned (typically 4KB)
62+
// which should be larger than any possible alignment value.
6163
if (ptr.as_ptr() as *mut u8).align_offset(layout.align()) != 0 {
6264
unsafe { memsec::free_memfd_secret(ptr) };
6365
return Err(AllocError);

0 commit comments

Comments
 (0)