From 3237f2dd7f0a029e0c54a4a97f9925721cdb9347 Mon Sep 17 00:00:00 2001 From: ChristopherHX Date: Wed, 2 Sep 2020 21:51:05 +0200 Subject: [PATCH] Accept (sockaddr*)nullptr, len = 0, in sendto Get called like this in Minecraft 1.16.100.52/3 --- src/network.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/network.h b/src/network.h index 8de35b0..5865788 100644 --- a/src/network.h +++ b/src/network.h @@ -185,11 +185,15 @@ namespace shim { socklen_t len = sizeof(sockaddr_storage); sockaddr_in(const bionic::sockaddr *addr, socklen_t) { - bionic::to_host(addr, ptr()); - len = bionic::get_host_len(addr); + if (addr) { + bionic::to_host(addr, ptr()); + len = bionic::get_host_len(addr); + } else { + len = 0; + } } - ::sockaddr *ptr() { return (::sockaddr *) &haddr; } + ::sockaddr *ptr() { return len ? (::sockaddr *) &haddr : nullptr; } }; struct sockaddr_out { @@ -221,4 +225,4 @@ namespace shim { } -} \ No newline at end of file +}