summaryrefslogtreecommitdiff
path: root/Python/fileutils.c
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-02-18 10:58:09 -0800
committerGitHub <noreply@github.com>2018-02-18 10:58:09 -0800
commit65a13c19e86488119cc9bc192f5a0b846d90940f (patch)
tree32b0580a19cf8bcd694948dc5444d81a6e3de379 /Python/fileutils.c
parent17ca4e193ea25f13a5f0309a0713a6b5bedaf3e4 (diff)
downloadcpython-git-65a13c19e86488119cc9bc192f5a0b846d90940f.tar.gz
bpo-32869: Fix incorrect dst buffer size for MultiByteToWideChar (GH-5739)
This function expects the destination buffer size to be given in wide characters, not bytes. (cherry picked from commit b3b4a9d3001f1fc7df8efcccdce081de54fa5eab) Co-authored-by: Alexey Izbyshev <izbyshev@users.noreply.github.com>
Diffstat (limited to 'Python/fileutils.c')
-rw-r--r--Python/fileutils.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/Python/fileutils.c b/Python/fileutils.c
index 899ea8aeca..b9638d2df5 100644
--- a/Python/fileutils.c
+++ b/Python/fileutils.c
@@ -1185,7 +1185,8 @@ _Py_fopen_obj(PyObject *path, const char *mode)
if (wpath == NULL)
return NULL;
- usize = MultiByteToWideChar(CP_ACP, 0, mode, -1, wmode, sizeof(wmode));
+ usize = MultiByteToWideChar(CP_ACP, 0, mode, -1,
+ wmode, Py_ARRAY_LENGTH(wmode));
if (usize == 0) {
PyErr_SetFromWindowsErr(0);
return NULL;