Prevent write-after-free by reordering Cast struct fields
Browse files at this commit- fix
- prevent write-after-free by reordering Cast struct fields
1 changed file +2 -1
- src/pw_utils.rs +2 -1
src/pw_utils.rsmodified+2 -1
| @@ -72,8 +72,9 @@ pub struct Cast { | |||
| 72 | event_loop: LoopHandle<'static, State>, | 72 | event_loop: LoopHandle<'static, State>, |
| 73 | pub session_id: usize, | 73 | pub session_id: usize, |
| 74 | pub stream_id: usize, | 74 | pub stream_id: usize, |
| 75 | - pub stream: StreamRc, | 75 | + // Listener is dropped before Stream to prevent a use-after-free. |
| 76 | _listener: StreamListener<()>, | 76 | _listener: StreamListener<()>, |
| 77 | + pub stream: StreamRc, | ||
| 77 | pub target: CastTarget, | 78 | pub target: CastTarget, |
| 78 | pub dynamic_target: bool, | 79 | pub dynamic_target: bool, |
| 79 | formats: FormatSet, | 80 | formats: FormatSet, |