Skip to content

Commit e8a060a

Browse files
committed
fix formatting
1 parent 740ea52 commit e8a060a

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

docs/rust-specific-mistakes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ Entries below are failure modes whose root cause is specific to Rust's language,
2222
**Common sub-pattern:** `len * size_of::<T>()` or `base + offset` wrapping silently, followed immediately by `alloc(wrapped_size)` and an `unsafe` write past the actual end.
2323

2424
**Mitigation:** Use `checked_mul`, `checked_add`, or enable `overflow-checks = true` in `[profile.release]` for safety-critical builds.
25+
2526
**Also in C/C++:** the same size-calculation-then-heap-overflow pattern is a classic C bug (`malloc(n * size)` overflowing before allocation); C leaves signed overflow as undefined behaviour and unsigned overflow as silent wraparound. What is Rust-specific here is the debug/release split and the `checked_*`/`overflow-checks` mitigation vocabulary.
27+
2628
---
2729

2830
### A.2 — Silent Truncation via `as` Casting

0 commit comments

Comments
 (0)