diff options
author | Philipp Keller <philipp.keller@gmail.com> | 2016-09-28 07:02:15 +0200 |
---|---|---|
committer | Philipp Keller <philipp.keller@gmail.com> | 2016-09-28 07:02:15 +0200 |
commit | 7c0f5e3598c2489d53259253842c7a74ece773cc (patch) | |
tree | 184bc95bc0af66a5ee705281f8e156e6fb002e40 | |
parent | 60a70c6b1e9fa201b686a6121650f27caa6ae932 (diff) | |
download | nix-7c0f5e3598c2489d53259253842c7a74ece773cc.zip |
Add debug_assert ensuring popped byte is nul
-rw-r--r-- | src/unistd.rs | 3 |
1 files changed, 2 insertions, 1 deletions
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<P: ?Sized + NixPath>(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))) |