about summary refs log tree commit diff
path: root/library/std/src/sys/windows/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'library/std/src/sys/windows/mod.rs')
-rw-r--r--library/std/src/sys/windows/mod.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/library/std/src/sys/windows/mod.rs b/library/std/src/sys/windows/mod.rs
index dc288176346..6097e628768 100644
--- a/library/std/src/sys/windows/mod.rs
+++ b/library/std/src/sys/windows/mod.rs
@@ -224,8 +224,14 @@ where
             } as usize;
             if k == n && c::GetLastError() == c::ERROR_INSUFFICIENT_BUFFER {
                 n *= 2;
-            } else if k >= n {
+            } else if k > n {
                 n = k;
+            } else if k == n {
+                // It is impossible to reach this point.
+                // On success, k is the returned string length excluding the null.
+                // On failure, k is the required buffer length including the null.
+                // Therefore k never equals n.
+                unreachable!();
             } else {
                 return Ok(f2(&buf[..k]));
             }