Commit 6cad6c2
Fix: reset pos when crossing segment boundary in find_offset_in_segments (#1772)
### WHAT is this pull request doing?
Fixes #1771
Restores the `pos = 4u32` reset in `find_offset_in_segments` when
advancing to the next segment.
In #1479, the original `pos = 4_u32` was changed to `rfile.pos = 4u32`.
During
[review](#1479 (comment))
it was mentioned that the method uses a local `pos` variable, not
`rfile.pos`. When resolving, the line was removed entirely instead of
being changed back to `pos = 4u32`.
Without the reset, when a timestamp-based `x-stream-offset` falls
between two segments, the method walks all messages in the first
segment, crosses to the next segment, and reads from the old segment's
end position, causing an `IndexError` or potentially a SEGFAULT.
### HOW can this pull request be tested?
Run added spec
---------
Co-authored-by: Viktor Erlingsson <[email protected]>1 parent 7c88f06 commit 6cad6c2
2 files changed
Lines changed: 27 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
224 | 250 | | |
225 | 251 | | |
226 | 252 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
108 | 109 | | |
109 | 110 | | |
110 | 111 | | |
| |||
0 commit comments