From cf58a32583ec1109c6bea883228f421a09211aaa Mon Sep 17 00:00:00 2001 From: GovanifY Date: Sat, 3 Oct 2020 21:55:40 +0200 Subject: [PATCH] DEV9: fix crash when closing game window with ethernet disabled --- plugins/dev9ghzdrk/Win32/tap-win32.cpp | 4 ++++ plugins/dev9ghzdrk/Win32/tap.h | 1 + 2 files changed, 5 insertions(+) diff --git a/plugins/dev9ghzdrk/Win32/tap-win32.cpp b/plugins/dev9ghzdrk/Win32/tap-win32.cpp index 35b0c87e2d..78a3831849 100644 --- a/plugins/dev9ghzdrk/Win32/tap-win32.cpp +++ b/plugins/dev9ghzdrk/Win32/tap-win32.cpp @@ -280,6 +280,7 @@ TAPAdapter::TAPAdapter() write.Offset = 0; write.OffsetHigh = 0; write.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); + isActive = true; } @@ -379,10 +380,13 @@ bool TAPAdapter::send(NetPacket* pkt) } TAPAdapter::~TAPAdapter() { + if (!isActive) + return; CloseHandle(read.hEvent); CloseHandle(write.hEvent); TAPSetStatus(htap, FALSE); CloseHandle(htap); + isActive = false; } //i leave these for reference, in case we need msth :p diff --git a/plugins/dev9ghzdrk/Win32/tap.h b/plugins/dev9ghzdrk/Win32/tap.h index 39230fed3e..57c5e0e82d 100644 --- a/plugins/dev9ghzdrk/Win32/tap.h +++ b/plugins/dev9ghzdrk/Win32/tap.h @@ -29,6 +29,7 @@ class TAPAdapter : public NetAdapter { HANDLE htap; OVERLAPPED read,write; + bool isActive = false; public: TAPAdapter(); virtual bool blocks();