do not init and copy to ctr_dest_addr unless have data

This commit is contained in:
Nguyen Dac Nam 2018-08-21 20:51:13 +07:00 committed by GitHub
parent 3b736a72a5
commit e8bb79be2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -544,11 +544,10 @@ void SOC_U::SendTo(Kernel::HLERequestContext& ctx) {
auto input_buff = rp.PopStaticBuffer(); auto input_buff = rp.PopStaticBuffer();
auto dest_addr_buff = rp.PopStaticBuffer(); auto dest_addr_buff = rp.PopStaticBuffer();
CTRSockAddr ctr_dest_addr;
std::memcpy(&ctr_dest_addr, dest_addr_buff.data(), sizeof(ctr_dest_addr));
s32 ret = -1; s32 ret = -1;
if (addr_len > 0) { if (addr_len > 0) {
CTRSockAddr ctr_dest_addr;
std::memcpy(&ctr_dest_addr, dest_addr_buff.data(), sizeof(ctr_dest_addr));
sockaddr dest_addr = CTRSockAddr::ToPlatform(ctr_dest_addr); sockaddr dest_addr = CTRSockAddr::ToPlatform(ctr_dest_addr);
ret = ::sendto(socket_handle, reinterpret_cast<const char*>(input_buff.data()), len, flags, ret = ::sendto(socket_handle, reinterpret_cast<const char*>(input_buff.data()), len, flags,
&dest_addr, sizeof(dest_addr)); &dest_addr, sizeof(dest_addr));