From 7c0f5e3598c2489d53259253842c7a74ece773cc Mon Sep 17 00:00:00 2001 From: Philipp Keller Date: Wed, 28 Sep 2016 07:02:15 +0200 Subject: Add debug_assert ensuring popped byte is nul --- src/unistd.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/unistd.rs') diff --git a/src/unistd.rs b/src/unistd.rs index 4d4e7529..4226b2f7 100644 --- a/src/unistd.rs +++ b/src/unistd.rs @@ -538,7 +538,8 @@ pub fn mkstemp(template: &P) -> Result<(RawFd, PathBuf)> { let mut path = try!(template.with_nix_path(|path| {path.to_bytes_with_nul().to_owned()})); let p = path.as_mut_ptr() as *mut _; let fd = unsafe { libc::mkstemp(p) }; - path.pop(); // drop the trailing nul + let last = path.pop(); // drop the trailing nul + debug_assert!(last == Some(b'\0')); let pathname = OsString::from_vec(path); try!(Errno::result(fd)); Ok((fd, PathBuf::from(pathname))) -- cgit v1.2.3