Commit d8b9a4a
abacus_fixer
fix: prevent out-of-bounds write in write_save_to_flat for nspin=1
For nspin==1, uom_save is allocated as a single block (pot_index is
doubled only when nspin==2). However, write_save_to_flat previously
wrote both spin channels unconditionally, causing part of the first
block to be overwritten and indices past the vector end to be accessed
(undefined behavior via operator[]).
Fix by guarding the channel-[1] write with `if (nspin_ == 2)`,
consistent with write_to_flat() and read_from_flat() which already
handle the two channels correctly.1 parent e8c2852 commit d8b9a4a
1 file changed
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
294 | | - | |
295 | 294 | | |
296 | 295 | | |
297 | 296 | | |
298 | | - | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
299 | 305 | | |
300 | 306 | | |
301 | 307 | | |
| |||
0 commit comments