Commit 8db338b
authored
fix(simplestream): move json_length to outer scope to prevent dangling pointer (#1107)
In sendJSON mode, `uint32_t json_length` was declared inside the
`if (stream.sendJSON==true)` block, but the `send_to()`/`send()` call
that reads from the scatter-gather buffer is outside that block. By the
time the UDP send executes, `json_length` has gone out of scope and its
stack memory may be reclaimed — causing the 4-byte length prefix in the
packet to contain garbage data instead of the actual JSON length.
Move `json_length` to the same scope as `send_buffer` so it remains
alive at send time. Fixes all three affected functions: `audio_stream`,
`call_start`, and `call_end`.
Fixes #11061 parent debaf83 commit 8db338b
1 file changed
Lines changed: 6 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| 107 | + | |
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
| |||
117 | 118 | | |
118 | 119 | | |
119 | 120 | | |
120 | | - | |
| 121 | + | |
121 | 122 | | |
122 | 123 | | |
123 | 124 | | |
| |||
180 | 181 | | |
181 | 182 | | |
182 | 183 | | |
| 184 | + | |
183 | 185 | | |
184 | 186 | | |
185 | 187 | | |
| |||
194 | 196 | | |
195 | 197 | | |
196 | 198 | | |
197 | | - | |
| 199 | + | |
198 | 200 | | |
199 | 201 | | |
200 | 202 | | |
| |||
231 | 233 | | |
232 | 234 | | |
233 | 235 | | |
| 236 | + | |
234 | 237 | | |
235 | 238 | | |
236 | 239 | | |
| |||
241 | 244 | | |
242 | 245 | | |
243 | 246 | | |
244 | | - | |
| 247 | + | |
245 | 248 | | |
246 | 249 | | |
247 | 250 | | |
| |||
0 commit comments