From 30abbf53ae9bd22dd58764d95a36e1add131654c Mon Sep 17 00:00:00 2001 From: Olaf Buddenhagen Date: Fri, 8 Jan 2016 09:00:55 +0100 Subject: [PATCH] Linux: Don't pass uninitialised memory as pointers to libc::connect() I don't know whether there are constellations where taking a reference to a binding containing mem::uninitialized() actually creates a proper NULL pointer -- but it certainly doesn't on my system when using the rustc snapshot from Servo. Either way, creating explicit NULL pointers seems way more correct. This fixes the other four testsuite failures, as well as servo -M --- platform/linux/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platform/linux/mod.rs b/platform/linux/mod.rs index 7ee17c356..e30817b5d 100644 --- a/platform/linux/mod.rs +++ b/platform/linux/mod.rs @@ -474,9 +474,9 @@ impl UnixOneShotServer { Vec, Vec),UnixError> { unsafe { - let mut sockaddr = mem::uninitialized(); - let mut sockaddr_len = mem::uninitialized(); - let client_fd = libc::accept(self.fd, &mut sockaddr, &mut sockaddr_len); + let sockaddr: *mut sockaddr = ptr::null_mut(); + let sockaddr_len: *mut socklen_t = ptr::null_mut(); + let client_fd = libc::accept(self.fd, sockaddr, sockaddr_len); if client_fd < 0 { return Err(UnixError::last()) }