summaryrefslogtreecommitdiff
path: root/src/unistd.rs
diff options
context:
space:
mode:
authorPhilipp Keller <philipp.keller@gmail.com>2016-09-28 07:02:15 +0200
committerPhilipp Keller <philipp.keller@gmail.com>2016-09-28 07:02:15 +0200
commit7c0f5e3598c2489d53259253842c7a74ece773cc (patch)
tree184bc95bc0af66a5ee705281f8e156e6fb002e40 /src/unistd.rs
parent60a70c6b1e9fa201b686a6121650f27caa6ae932 (diff)
downloadnix-7c0f5e3598c2489d53259253842c7a74ece773cc.zip
Add debug_assert ensuring popped byte is nul
Diffstat (limited to 'src/unistd.rs')
-rw-r--r--src/unistd.rs3
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)))