Skip to content

Commit 65a13c1

Browse files
bpo-32869: Fix incorrect dst buffer size for MultiByteToWideChar (pythonGH-5739)
This function expects the destination buffer size to be given in wide characters, not bytes. (cherry picked from commit b3b4a9d) Co-authored-by: Alexey Izbyshev <[email protected]>
1 parent 17ca4e1 commit 65a13c1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Diff for: Python/fileutils.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,8 @@ _Py_fopen_obj(PyObject *path, const char *mode)
11851185
if (wpath == NULL)
11861186
return NULL;
11871187

1188-
usize = MultiByteToWideChar(CP_ACP, 0, mode, -1, wmode, sizeof(wmode));
1188+
usize = MultiByteToWideChar(CP_ACP, 0, mode, -1,
1189+
wmode, Py_ARRAY_LENGTH(wmode));
11891190
if (usize == 0) {
11901191
PyErr_SetFromWindowsErr(0);
11911192
return NULL;

0 commit comments

Comments
 (0)