Skip to content

Commit ca82e3c

Browse files
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 b3b4a9d) Co-authored-by: Alexey Izbyshev <izbyshev@users.noreply.github.com>
1 parent 2e84e47 commit ca82e3c

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Python/fileutils.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,8 @@ _Py_fopen_obj(PyObject *path, const char *mode)
12891289
if (wpath == NULL)
12901290
return NULL;
12911291

1292-
usize = MultiByteToWideChar(CP_ACP, 0, mode, -1, wmode, sizeof(wmode));
1292+
usize = MultiByteToWideChar(CP_ACP, 0, mode, -1,
1293+
wmode, Py_ARRAY_LENGTH(wmode));
12931294
if (usize == 0) {
12941295
PyErr_SetFromWindowsErr(0);
12951296
return NULL;

0 commit comments

Comments
 (0)