citra-emu
/
citra
Archived
1
0
Fork 0

only get src_adr if input_adr available

This commit is contained in:
Nguyen Dac Nam 2018-08-21 21:33:19 +07:00 committed by GitHub
parent e8bb79be2d
commit 0e89555a89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 5 deletions

View File

@ -580,13 +580,19 @@ void SOC_U::RecvFrom(Kernel::HLERequestContext& ctx) {
std::vector<u8> addr_buff(sizeof(ctr_src_addr)); std::vector<u8> addr_buff(sizeof(ctr_src_addr));
sockaddr src_addr; sockaddr src_addr;
socklen_t src_addr_len = sizeof(src_addr); socklen_t src_addr_len = sizeof(src_addr);
s32 ret = ::recvfrom(socket_handle, reinterpret_cast<char*>(output_buff.data()), len, flags,
&src_addr, &src_addr_len);
if (ret >= 0 && src_addr_len > 0) { s32 ret = -1;
ctr_src_addr = CTRSockAddr::FromPlatform(src_addr); if (addr_len > 0) {
std::memcpy(addr_buff.data(), &ctr_src_addr, sizeof(ctr_src_addr)); // Only get src adr if input adr available
ret = ::recvfrom(socket_handle, reinterpret_cast<char*>(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 { } else {
ret = ::recvfrom(socket_handle, reinterpret_cast<char*>(output_buff.data()), len, flags,
NULL, 0);
addr_buff.resize(0); addr_buff.resize(0);
} }