GitHub Advisoryadvisory · crates.io

GHSA-wm8x-php5-hvq6 Maligned causes incorrect deallocation

MEDIUM Published 2023-03-07 Modified 2023-03-07 Official page ↗
Ecosystem
crates.io
Packages
maligned
Severity
Moderate
Reviewed
2023-03-07

Affected packages

• crates.io maligned: <= 0.2.1 (no fix yet)

Description

`maligned::align_first` manually allocates with an alignment larger than T, and then uses `Vec::from_raw_parts` on that allocation to get a `Vec`. `GlobalAlloc::dealloc` requires that the `layout` argument must be the same layout that was used to allocate that block of memory. When deallocating, `Box` and `Vec` may not respect the specified alignment and can cause undefined behavior.

References