Skip to content

Commit

Permalink
Merge pull request #14 from AnthonyMikh/fix/truncate_over_resize
Browse files Browse the repository at this point in the history
Truncate instead of resize in unix impl
  • Loading branch information
swsnr committed May 4, 2024
2 parents e40fd93 + 2090353 commit 507a59a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fn gethostname_impl() -> OsString {
// doesn't specify whether there's a NUL byte at the end, so if we didn't
// check we might read from memory that's not ours.
let end = buffer.iter().position(|&b| b == 0).unwrap_or(buffer.len());
buffer.resize(end, 0);
buffer.truncate(end);
OsString::from_vec(buffer)
}

Expand Down

0 comments on commit 507a59a

Please sign in to comment.