Description
This is about this code:
rust/library/std/src/sys/pal/windows/os.rs
Lines 327 to 340 in b58f647
According to the docs, the size pointer is updated as follows:
"If the buffer specified by lpProfileDir is not large enough or lpProfileDir is NULL, the function fails and this parameter receives the necessary buffer size, including the terminating null character."
The docs say nothing about what happens to the size pointer if the buffer is large enough (and not NULL). std however assumes that in that case, the size pointer is updated to the actual length of the data (including the null terminator). Reality seems to agree as otherwise we'd long have seen issues (and FWIW, wine agrees as well). Still, we're technically relying on undocumented behavior here.
Probably the best way forward is for the Windows docs to be updated.