Skip to content

Commit 4ddde64

Browse files
max630dscho
authored andcommitted
mingw: consider that UNICODE_STRING::Length counts bytes
UNICODE_STRING::Length field means size of buffer in bytes[1], despite of buffer itself being array of wchar_t. Because of that terminating zero is placed twice as far. Fix it. [1] https://msdn.microsoft.com/en-us/library/windows/desktop/aa380518.aspx Signed-off-by: Max Kirillov <[email protected]> Acked-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 58e7864 commit 4ddde64

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

compat/winansi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ static void detect_msys_tty(int fd)
553553
buffer, sizeof(buffer) - 2, &result)))
554554
return;
555555
name = nameinfo->Name.Buffer;
556-
name[nameinfo->Name.Length] = 0;
556+
name[nameinfo->Name.Length / sizeof(*name)] = 0;
557557

558558
/* check if this could be a MSYS2 pty pipe ('msys-XXXX-ptyN-XX') */
559559
if (!wcsstr(name, L"msys-") || !wcsstr(name, L"-pty"))

0 commit comments

Comments
 (0)