From 28e3618e79ba027c28d2d651675f987b4347dfa9 Mon Sep 17 00:00:00 2001 From: James Ross-Gowan Date: Sat, 29 Jul 2017 21:13:07 +1000 Subject: subprocess-win: fix swprintf usage The count parameter refers to the number of wide-characters to write to the buffer (including the terminating NUL character, which is always added,) not the number of bytes. See C99 7.24.2.3 or https://msdn.microsoft.com/en-us/library/ybk95axf.aspx --- osdep/subprocess-win.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osdep/subprocess-win.c b/osdep/subprocess-win.c index c662fb6301..5df09cda78 100644 --- a/osdep/subprocess-win.c +++ b/osdep/subprocess-win.c @@ -112,7 +112,8 @@ static int create_overlapped_pipe(HANDLE *read, HANDLE *write) unsigned long id = atomic_fetch_add(&counter, 1); unsigned pid = GetCurrentProcessId(); wchar_t buf[36]; - swprintf(buf, sizeof(buf), L"\\\\.\\pipe\\mpv-anon-%08x-%08lx", pid, id); + swprintf(buf, MP_ARRAY_SIZE(buf), L"\\\\.\\pipe\\mpv-anon-%08x-%08lx", + pid, id); // The function for creating anonymous pipes (CreatePipe) can't create // overlapped pipes, so instead, use a named pipe with a unique name -- cgit v1.2.3