[Python-checkins] bpo-32869: Fix incorrect dst buffer size for MultiByteToWideChar (#5739)
Serhiy Storchaka
webhook-mailer at python.org
Sun Feb 18 12:57:27 EST 2018
https://github.com/python/cpython/commit/b3b4a9d3001f1fc7df8efcccdce081de54fa5eab
commit: b3b4a9d3001f1fc7df8efcccdce081de54fa5eab
branch: master
author: Alexey Izbyshev <izbyshev at users.noreply.github.com>
committer: Serhiy Storchaka <storchaka at gmail.com>
date: 2018-02-18T19:57:24+02:00
summary:
bpo-32869: Fix incorrect dst buffer size for MultiByteToWideChar (#5739)
This function expects the destination buffer size to be given
in wide characters, not bytes.
files:
M Python/fileutils.c
diff --git a/Python/fileutils.c b/Python/fileutils.c
index 3cf8b7a8b69d..32aeea4f1037 100644
--- a/Python/fileutils.c
+++ b/Python/fileutils.c
@@ -1289,7 +1289,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;
More information about the Python-checkins
mailing list