We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 4de06d4 + 57442be commit 28d06bdCopy full SHA for 28d06bd
library/std/src/sys/windows/mod.rs
@@ -224,8 +224,14 @@ where
224
} as usize;
225
if k == n && c::GetLastError() == c::ERROR_INSUFFICIENT_BUFFER {
226
n *= 2;
227
- } else if k >= n {
+ } else if k > n {
228
n = k;
229
+ } else if k == n {
230
+ // It is impossible to reach this point.
231
+ // On success, k is the returned string length excluding the null.
232
+ // On failure, k is the required buffer length including the null.
233
+ // Therefore k never equals n.
234
+ unreachable!();
235
} else {
236
return Ok(f2(&buf[..k]));
237
}
0 commit comments