Commit df61a9a
committed
Fix clad::array copy-assignment over-reading a shorter source.
array<T>::operator=(const array<T>&) only reallocated when the
destination was smaller than the source, so a larger destination kept
its old m_size and then copied that many elements from the shorter
source -- a heap over-read Valgrind flags in Jacobian/Jacobian.C and
Jacobian/testUtility.C once the clang false positives are suppressed.
Adopt the source size before copying so the loop is bounded by the
source. The buffer may exceed m_size after a shrink, which is harmless:
m_size bounds every access and the destructor frees the whole buffer.1 parent 5019711 commit df61a9a
3 files changed
Lines changed: 4 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
102 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
103 | 106 | | |
104 | 107 | | |
105 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | 3 | | |
6 | 4 | | |
7 | 5 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | 3 | | |
6 | 4 | | |
7 | 5 | | |
| |||
0 commit comments