From 3b00bcc8bc8e2813b416563092d5392cb5e6ea01 Mon Sep 17 00:00:00 2001 From: Noethix55555 <277300782+Noethix55555@users.noreply.github.com> Date: Wed, 17 Jun 2026 22:52:33 -0400 Subject: [PATCH] fix: destroy client handles before the mpv core in Destroy() --- src/MpvNet/Player.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/MpvNet/Player.cs b/src/MpvNet/Player.cs index 25310545..0a0ba118 100644 --- a/src/MpvNet/Player.cs +++ b/src/MpvNet/Player.cs @@ -192,13 +192,16 @@ public void Init(IntPtr formHandle, bool processCommandLine) public void Destroy() { - mpv_destroy(MainHandle); + // Destroy client handles before the core; destroying the core first + // leaves the client handle pointing at freed memory (use-after-destroy). mpv_destroy(Handle); foreach (var client in Clients) { mpv_destroy(client.Handle); } + + mpv_destroy(MainHandle); } public void ProcessProperty(string? name, string? value)