Skip to content

Commit 3c36d29

Browse files
authored
Rollup merge of #141405 - RalfJung:GetUserProfileDirectoryW, r=ChrisDenton
GetUserProfileDirectoryW is now documented to always store the size Update to match MicrosoftDocs/sdk-api#1810 Also fix a bug in the Miri implementation while I am starting at that code... r? ```@ChrisDenton``` Fixes #141254
2 parents a4ef10e + 48e9b86 commit 3c36d29

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/shims/windows/env.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,16 +230,16 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
230230
interp_ok(match directories::UserDirs::new() {
231231
Some(dirs) => {
232232
let home = dirs.home_dir();
233-
let size_avail = if this.ptr_is_null(size.ptr())? {
233+
let size_avail = if this.ptr_is_null(buf)? {
234234
0 // if the buf pointer is null, we can't write to it; `size` will be updated to the required length
235235
} else {
236236
this.read_scalar(&size)?.to_u32()?
237237
};
238238
// Of course we cannot use `windows_check_buffer_size` here since this uses
239239
// a different method for dealing with a too-small buffer than the other functions...
240240
let (success, len) = this.write_path_to_wide_str(home, buf, size_avail.into())?;
241-
// The Windows docs just say that this is written on failure, but std relies on it
242-
// always being written. Also see <https://github.com/rust-lang/rust/issues/141254>.
241+
// As per <https://github.com/MicrosoftDocs/sdk-api/pull/1810>, the size is always
242+
// written, not just on failure.
243243
this.write_scalar(Scalar::from_u32(len.try_into().unwrap()), &size)?;
244244
if success {
245245
Scalar::from_i32(1) // return TRUE

0 commit comments

Comments
 (0)