Skip to content

Commit

Permalink
xdv: fix a potential source of undefined behavior
Browse files Browse the repository at this point in the history
Fixes #752.
  • Loading branch information
pkgw committed Feb 18, 2021
1 parent c86ad41 commit cdff034
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions crates/xdv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,9 @@ impl<T: XdvEvents> XdvParser<T> {
{
const BUF_SIZE: usize = 4096;
let mut parser = Self::new(events);
let mut buf = Vec::with_capacity(BUF_SIZE);
unsafe {
buf.set_len(BUF_SIZE);
}
// Note that it is unsound to pass uninitialized data to a read() call,
// even though it *should* never cause problems ...
let mut buf = vec![0; BUF_SIZE];
let mut n_saved_bytes = 0;

loop {
Expand Down

0 comments on commit cdff034

Please sign in to comment.