Commit fccec82
authored
fix: avoid dereferencing past-the-end vector iterators in serialize.hpp (#22261)
## Summary
Two `write()` overloads in `serialize.hpp` used `&*buf.end()` to obtain
a raw pointer into the newly-resized region. Under `_GLIBCXX_DEBUG`
(enabled in asan-fast and debug presets since #22218), dereferencing
`end()` is a debug assertion abort — even though the subtracted pointer
was in-bounds.
Replaced with `buf.data() + buf.size()` which yields the same pointer
without touching any iterator.
## Failure
`ChonkTests.Basic` in the asan-fast build aborted with:
```
Error: attempt to dereference a past-the-end iterator.
```
## Fix
- `serialize.hpp:166`: `&*buf.end() - sizeof(value)` → `buf.data() +
buf.size() - sizeof(value)`
- `serialize.hpp:251`: `&*buf.end() - N` → `buf.data() + buf.size() - N`
## Test plan
- [x] `ChonkTests.Basic` passes with debug-fast preset (`_GLIBCXX_DEBUG`
enabled)
ClaudeBox log: https://claudebox.work/s/4aef0cbe07a366e4?run=11 parent ed6069d commit fccec82
1 file changed
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
166 | | - | |
| 166 | + | |
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
251 | | - | |
| 251 | + | |
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
| |||
0 commit comments