Commit 4d6cf6e
committed
trace2: fix incomplete disposal of writers on cleanup
ReleaseManagedResources iterates forward by index while removing
elements from the same list. Each removal shifts remaining elements
left, but the loop increments i, causing the next element to be
skipped. As a result, only about half of the writers are disposed and
removed, leaving file handles or buffers open.
Fix by iterating in reverse so that removals do not shift any unvisited
indices, and use RemoveAt(i) to avoid a redundant linear search.
Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>1 parent 33cf5e8 commit 4d6cf6e
1 file changed
Lines changed: 3 additions & 3 deletions
File tree
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
460 | 460 | | |
461 | 461 | | |
462 | 462 | | |
463 | | - | |
| 463 | + | |
464 | 464 | | |
465 | | - | |
| 465 | + | |
466 | 466 | | |
467 | | - | |
| 467 | + | |
468 | 468 | | |
469 | 469 | | |
470 | 470 | | |
| |||
0 commit comments