From ad9ec44228b79c219755ae839ab45164732ea3a6 Mon Sep 17 00:00:00 2001 From: Peter Tissen Date: Sat, 24 May 2014 22:12:26 +0200 Subject: [PATCH] prevent null dereference if no network device is selected in dev9 --- plugins/dev9ghzdrk/Win32/Win32.cpp | 7 ++++++- plugins/dev9ghzdrk/Win32/net.cpp | 13 ++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/plugins/dev9ghzdrk/Win32/Win32.cpp b/plugins/dev9ghzdrk/Win32/Win32.cpp index 6aa82b4c82..5436ced59b 100644 --- a/plugins/dev9ghzdrk/Win32/Win32.cpp +++ b/plugins/dev9ghzdrk/Win32/Win32.cpp @@ -171,8 +171,13 @@ s32 _DEV9open() //ResumeThread (handleDEV9Thread); NetAdapter* na=GetNetAdapter(); if (!na) + { emu_printf("Failed to GetNetAdapter()\n"); - InitNet( na); + } + else + { + InitNet(na); + } return 0; } diff --git a/plugins/dev9ghzdrk/Win32/net.cpp b/plugins/dev9ghzdrk/Win32/net.cpp index bb062442f6..11c213dcfc 100644 --- a/plugins/dev9ghzdrk/Win32/net.cpp +++ b/plugins/dev9ghzdrk/Win32/net.cpp @@ -57,10 +57,13 @@ void InitNet(NetAdapter* ad) } void TermNet() { - RxRunning=false; - emu_printf("Waiting for RX-net thread to terminate.."); - WaitForSingleObject(rx_thread,-1); - emu_printf(".done\n"); + if(RxRunning) + { + RxRunning = false; + emu_printf("Waiting for RX-net thread to terminate.."); + WaitForSingleObject(rx_thread, -1); + emu_printf(".done\n"); - delete nif; + delete nif; + } } \ No newline at end of file