Skip to content

Commit 218374f

Browse files
committed
Fix off-by-one error
1 parent 5a5120e commit 218374f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

wlines.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,8 @@ void parseStdinEntries(state_t *state)
531531

532532
// Convert to utf16
533533
const size_t charCount = MultiByteToWideChar(CP_UTF8, 0, stdinUtf8.data, stdinUtf8.count, 0, 0);
534-
wchar_t *stdinUtf16 = xrealloc(0, charCount * 2);
535-
memset(stdinUtf16, 0, charCount * 2);
534+
wchar_t *stdinUtf16 = xrealloc(0, charCount * 2 + 1);
535+
memset(stdinUtf16, 0, charCount * 2 + 1);
536536
MultiByteToWideChar(CP_UTF8, 0, stdinUtf8.data, stdinUtf8.count, stdinUtf16, charCount);
537537
free(stdinUtf8.data);
538538

0 commit comments

Comments
 (0)