From 3fd08b6ceeb693863b3126f31a353aa7e5e926b3 Mon Sep 17 00:00:00 2001 From: Sepalani Date: Wed, 1 Feb 2017 00:11:19 +0000 Subject: [PATCH] Fixes a crash when closing a socket --- Source/Core/Core/IOS/Network/Socket.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/IOS/Network/Socket.cpp b/Source/Core/Core/IOS/Network/Socket.cpp index bd96a265f6..0a73305962 100644 --- a/Source/Core/Core/IOS/Network/Socket.cpp +++ b/Source/Core/Core/IOS/Network/Socket.cpp @@ -615,9 +615,13 @@ s32 WiiSockMan::NewSocket(s32 af, s32 type, s32 protocol) s32 WiiSockMan::DeleteSocket(s32 s) { + s32 ReturnValue = EBADF; auto socket_entry = WiiSockets.find(s); - s32 ReturnValue = socket_entry->second.CloseFd(); - WiiSockets.erase(socket_entry); + if (socket_entry != WiiSockets.end()) + { + ReturnValue = socket_entry->second.CloseFd(); + WiiSockets.erase(socket_entry); + } return ReturnValue; }