summaryrefslogtreecommitdiffstats
path: root/PC
diff options
context:
space:
mode:
authorPaul Moore <p.f.moore@gmail.com>2022-07-16 09:02:22 (GMT)
committerGitHub <noreply@github.com>2022-07-16 09:02:22 (GMT)
commit407ff6556cc999d692b264466ad8d32304a09bce (patch)
tree8c8f44ea7c6fdcc0465dec1c74b633c52a93dcae /PC
parentbbb2ab70b6d42c097dc35caa4d816ff7476d6554 (diff)
downloadcpython-407ff6556cc999d692b264466ad8d32304a09bce.zip
cpython-407ff6556cc999d692b264466ad8d32304a09bce.tar.gz
cpython-407ff6556cc999d692b264466ad8d32304a09bce.tar.bz2
gh-94772: Fix off-by-one error in Windows launcher (GH-94779)
Diffstat (limited to 'PC')
-rw-r--r--PC/launcher2.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/PC/launcher2.c b/PC/launcher2.c
index ae11f4f..c8ed1b0 100644
--- a/PC/launcher2.c
+++ b/PC/launcher2.c
@@ -874,7 +874,9 @@ checkShebang(SearchInfo *search)
while (--bytesRead > 0 && *++b != '\r' && *b != '\n') { }
wchar_t *shebang;
int shebangLength;
- int exitCode = _decodeShebang(search, start, (int)(b - start + 1), onlyUtf8, &shebang, &shebangLength);
+ // We add 1 when bytesRead==0, as in that case we hit EOF and b points
+ // to the last character in the file, not the newline
+ int exitCode = _decodeShebang(search, start, (int)(b - start + (bytesRead == 0)), onlyUtf8, &shebang, &shebangLength);
if (exitCode) {
return exitCode;
}