Skip to content

Commit 13bf15a

Browse files
authored
id-map: free uninitialized memory on drop
1 parent e8656e0 commit 13bf15a

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

crates/id-map/RUSTSEC-0000-0000.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
```toml
2+
[advisory]
3+
id = "RUSTSEC-0000-0000"
4+
package = "id-map"
5+
date = "2025-08-14"
6+
7+
url = "https://github.com/andrewhickman/id-map/issues/4"
8+
categories = ["memory-corruption"]
9+
keywords = ["memory-safety", "uninitialized-memory"]
10+
11+
[affected.functions]
12+
"id_map::IdMap::from_iter" = [">= 0.1.6, <= 0.2.1"]
13+
14+
[versions]
15+
patched = [">= 0.2.2"]
16+
unaffected = ["< 0.1.6"]
17+
```
18+
19+
# IdMap::from_iter may lead to uninitialized memory being freed on drop
20+
21+
Due to a flaw in the constructor `id_map::IdMap::from_iter`, ill-formed objects may be created in which the amount of actually initialized memory is less than what is expected by the fields of `IdMap`. Specifically, the field `ids` is initialized based on the capacity of the vector `values`, which is constructed from the provided iterator. However, the length of this vector may be smaller than its capacity.
22+
23+
In such cases, when the resulting `IdMap` is dropped, its destructor incorrectly assumes that `values` contains `ids.len() == values.capacity()` initialized elements and attempts to iterate over and drop them. This leads to dereferencing and attempting to free uninitialized memory, resulting in undefined behavior and potential segmentation faults.
24+
25+
The bug was fixed in commit `fab6922`, and all unsafe code was removed from the crate.
26+
27+
Note that the maintainer recommends using the following alternatives:
28+
- [slab](https://crates.io/crates/slab)
29+
- [slotmap](https://crates.io/crates/slotmap)

0 commit comments

Comments
 (0)