Commit 9149a53
NimBLEAttValue.cpp - preserve capacity after realloc failure
NimBLEAttValue::append advanced m_capacity immediately after calling realloc.
If realloc failed, the original buffer remained allocated but the object advertised a larger capacity
than it actually owned. A later append could then skip reallocation and copy past the end of the allocation.
Track whether the append actually needs growth and only update m_capacity after the realloc result
passes the null check. Appends that fit the existing allocation leave capacity unchanged;
failed growth preserves the old capacity invariant.1 parent 657583a commit 9149a53
1 file changed
Lines changed: 7 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
128 | | - | |
129 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
137 | 141 | | |
138 | 142 | | |
139 | 143 | | |
| |||
0 commit comments