Skip to content

Commit b3b4a9d

Browse files
izbyshevserhiy-storchaka
authored andcommitted
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.
1 parent e8eb972 commit b3b4a9d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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)