Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/neat-pens-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@livekit/rtc-node': patch
---

Clear pending timeout in AudioSource.close() to prevent use-after-free
8 changes: 8 additions & 0 deletions packages/livekit-rtc/src/audio_source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ export class AudioSource {
}

async close() {
// Clear any pending playout timeout so its callback doesn't fire after
// the handle is disposed, which would reference freed native state.
if (this.timeout) {
clearTimeout(this.timeout);
this.timeout = undefined;
}
// Resolve any pending waitForPlayout() promise so callers don't hang.
this.release();
this.ffiHandle.dispose();
this.closed = true;
}
Expand Down
Loading