@@ -16,6 +16,7 @@ use std::{
16
16
use winapi:: {
17
17
shared:: { minwindef:: TRUE , winerror:: ERROR_INSUFFICIENT_BUFFER } ,
18
18
um:: {
19
+ errhandlingapi:: GetLastError ,
19
20
handleapi:: { CloseHandle , INVALID_HANDLE_VALUE } ,
20
21
minwinbase:: SECURITY_ATTRIBUTES ,
21
22
processthreadsapi:: {
@@ -148,14 +149,14 @@ pub(in crate::windows) fn spawn(
148
149
let mut startup_info: STARTUPINFOEXW = std:: mem:: zeroed ( ) ;
149
150
let mut proc_thread_attr_list_len = 0 ;
150
151
{
151
- let ret = InitializeProcThreadAttributeList (
152
+ InitializeProcThreadAttributeList (
152
153
std:: ptr:: null_mut ( ) ,
153
154
// we need only one attribute: security capabilities.
154
155
1 ,
155
156
0 ,
156
157
& mut proc_thread_attr_list_len,
157
158
) ;
158
- if ret != ERROR_INSUFFICIENT_BUFFER as i32 {
159
+ if GetLastError ( ) != ERROR_INSUFFICIENT_BUFFER {
159
160
return Err ( Error :: last ( ) ) ;
160
161
}
161
162
}
@@ -210,7 +211,9 @@ pub(in crate::windows) fn spawn(
210
211
// inherit handles
211
212
TRUE ,
212
213
creation_flags,
213
- env. as_mut_ptr ( ) . cast ( ) ,
214
+ // TEMP DEBUG
215
+ std:: ptr:: null_mut ( ) ,
216
+ //env.as_mut_ptr().cast(),
214
217
cwd. as_ptr ( ) ,
215
218
( & mut startup_info as * mut STARTUPINFOEXW ) . cast ( ) ,
216
219
& mut info,
@@ -238,6 +241,7 @@ fn quote_arg(out: &mut Vec<u16>, data: &OsStr) {
238
241
out. push ( ascii_to_u16 ( b'"' ) ) ;
239
242
}
240
243
244
+ #[ derive( Eq , PartialEq ) ]
241
245
enum EncodeEnvResult {
242
246
/// Success
243
247
Ok ,
@@ -264,8 +268,11 @@ fn encode_env(data: &[OsString]) -> (Vec<u16>, EncodeEnvResult) {
264
268
out. push ( 0 ) ;
265
269
}
266
270
out. push ( 0 ) ;
271
+
267
272
// let's verify capacity was correct
268
273
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
+ }
270
277
( out, res)
271
278
}
0 commit comments