SIGN IN SIGN UP

fix(memory): use checked arithmetic in memfd_backed region sum

The memfd_backed function used an unchecked .sum() to calculate the
total size of memory regions. This could theoretically overflow if
given sufficiently large region sizes.

This change applies the same fix that was made to snapshot_file in
commit 837c2e782: replace the unchecked sum with try_fold and
checked_add, returning MemoryError::OffsetTooLarge on overflow.

Also add a unit test covering the overflow case.

Signed-off-by: Daniel Alejandro Dominguez Diaz <danielfromarg@gmail.com>
D
Daniel Alejandro Dominguez Diaz committed
4c9980549be299bfeeb3da13a7d56ab49e305751
Parent: a6146c8
Committed by Takahiro Itazuri <77261350+zulinx86@users.noreply.github.com> on 9/2/2026, 10:41:14 AM