From 0e89555a89deaf0d94de3a63e3facd56b7d7a2c7 Mon Sep 17 00:00:00 2001 From: Nguyen Dac Nam Date: Tue, 21 Aug 2018 21:33:19 +0700 Subject: [PATCH] only get src_adr if input_adr available --- src/core/hle/service/soc_u.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/core/hle/service/soc_u.cpp b/src/core/hle/service/soc_u.cpp index a0177d4fa..bcbcc4b4c 100644 --- a/src/core/hle/service/soc_u.cpp +++ b/src/core/hle/service/soc_u.cpp @@ -580,13 +580,19 @@ void SOC_U::RecvFrom(Kernel::HLERequestContext& ctx) { std::vector addr_buff(sizeof(ctr_src_addr)); sockaddr src_addr; socklen_t src_addr_len = sizeof(src_addr); - s32 ret = ::recvfrom(socket_handle, reinterpret_cast(output_buff.data()), len, flags, - &src_addr, &src_addr_len); - if (ret >= 0 && src_addr_len > 0) { - ctr_src_addr = CTRSockAddr::FromPlatform(src_addr); - std::memcpy(addr_buff.data(), &ctr_src_addr, sizeof(ctr_src_addr)); + s32 ret = -1; + if (addr_len > 0) { + // Only get src adr if input adr available + ret = ::recvfrom(socket_handle, reinterpret_cast(output_buff.data()), len, flags, + &src_addr, &src_addr_len); + if (ret >= 0 && src_addr_len > 0) { + ctr_src_addr = CTRSockAddr::FromPlatform(src_addr); + std::memcpy(addr_buff.data(), &ctr_src_addr, sizeof(ctr_src_addr)); + } } else { + ret = ::recvfrom(socket_handle, reinterpret_cast(output_buff.data()), len, flags, + NULL, 0); addr_buff.resize(0); }