Skip to content

Commit 94358e3

Browse files
committed
fix
1 parent 4633fd7 commit 94358e3

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/windows/spawn.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use std::{
1616
use winapi::{
1717
shared::{minwindef::TRUE, winerror::ERROR_INSUFFICIENT_BUFFER},
1818
um::{
19+
errhandlingapi::GetLastError,
1920
handleapi::{CloseHandle, INVALID_HANDLE_VALUE},
2021
minwinbase::SECURITY_ATTRIBUTES,
2122
processthreadsapi::{
@@ -148,14 +149,14 @@ pub(in crate::windows) fn spawn(
148149
let mut startup_info: STARTUPINFOEXW = std::mem::zeroed();
149150
let mut proc_thread_attr_list_len = 0;
150151
{
151-
let ret = InitializeProcThreadAttributeList(
152+
InitializeProcThreadAttributeList(
152153
std::ptr::null_mut(),
153154
// we need only one attribute: security capabilities.
154155
1,
155156
0,
156157
&mut proc_thread_attr_list_len,
157158
);
158-
if ret != ERROR_INSUFFICIENT_BUFFER as i32 {
159+
if GetLastError() != ERROR_INSUFFICIENT_BUFFER {
159160
return Err(Error::last());
160161
}
161162
}
@@ -210,7 +211,9 @@ pub(in crate::windows) fn spawn(
210211
// inherit handles
211212
TRUE,
212213
creation_flags,
213-
env.as_mut_ptr().cast(),
214+
// TEMP DEBUG
215+
std::ptr::null_mut(),
216+
//env.as_mut_ptr().cast(),
214217
cwd.as_ptr(),
215218
(&mut startup_info as *mut STARTUPINFOEXW).cast(),
216219
&mut info,
@@ -238,6 +241,7 @@ fn quote_arg(out: &mut Vec<u16>, data: &OsStr) {
238241
out.push(ascii_to_u16(b'"'));
239242
}
240243

244+
#[derive(Eq, PartialEq)]
241245
enum EncodeEnvResult {
242246
/// Success
243247
Ok,
@@ -264,8 +268,11 @@ fn encode_env(data: &[OsString]) -> (Vec<u16>, EncodeEnvResult) {
264268
out.push(0);
265269
}
266270
out.push(0);
271+
267272
// let's verify capacity was correct
268273
debug_assert_eq!(out.capacity(), capacity);
269-
debug_assert_eq!(out.len(), capacity);
274+
if res == EncodeEnvResult::Ok {
275+
debug_assert_eq!(out.len(), capacity);
276+
}
270277
(out, res)
271278
}

0 commit comments

Comments
 (0)