Skip to content

Commit 9cf950e

Browse files
committed
fix windows process output buffer access
1 parent e53ce80 commit 9cf950e

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎src/std/src/process/mod.cpp‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ auto Child::wait_with_output(OutputObserver observer) -> io::Result<Output> {
258258
while (true) {
259259
auto read = rstd::sys::io::stdio::read_fd(fd, chunk_buffer);
260260
if (read.is_err() || *read == usize()) break;
261-
auto chunk = slice<u8>::from_raw_parts(reinterpret_cast<const byte*>(tmp), *read);
261+
auto chunk = slice<u8>::from_raw_parts(chunk_buffer.as_byte_ptr(), *read);
262262
if (observer.notify != nullptr) observer.notify(observer.context, stream, chunk);
263263
buf.extend_from_slice(chunk);
264264
}
@@ -765,10 +765,11 @@ auto child_environment(bool clear, const ::alloc::vec::Vec<rstd::process::EnvAct
765765

766766
for (const auto& action : actions) {
767767
if (action.key.is_empty()) return Err(invalid_process_input());
768-
for (auto byte : action.key.as_os_str().as_encoded_bytes()) {
768+
auto key_os = action.key.as_os_str();
769+
for (auto byte : key_os.as_encoded_bytes()) {
769770
if (byte == u8() || byte == u8('=')) return Err(invalid_process_input());
770771
}
771-
auto key = wide_string(action.key.as_os_str());
772+
auto key = wide_string(key_os);
772773
if (key.is_err()) return Err(rstd::move(key).unwrap_err());
773774
for (auto index = entries.len(); index != usize();) {
774775
--index;

0 commit comments

Comments
 (0)