diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-06-27 13:03:14 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-27 13:03:14 (GMT) |
commit | e613e6add5f07ff6aad5802924596b631b707d2a (patch) | |
tree | 8e3a53cf8a0851c17a2dc9bcbd975c2bec5ff846 /Modules/_io | |
parent | 65474b9d7a230943d4d3f1d7d51f77bb141240f0 (diff) | |
download | cpython-e613e6add5f07ff6aad5802924596b631b707d2a.zip cpython-e613e6add5f07ff6aad5802924596b631b707d2a.tar.gz cpython-e613e6add5f07ff6aad5802924596b631b707d2a.tar.bz2 |
bpo-30708: Check for null characters in PyUnicode_AsWideCharString(). (#2285)
Raise a ValueError if the second argument is NULL and the wchar_t\*
string contains null characters.
Diffstat (limited to 'Modules/_io')
-rw-r--r-- | Modules/_io/winconsoleio.c | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/Modules/_io/winconsoleio.c b/Modules/_io/winconsoleio.c index 781518a..6600fde 100644 --- a/Modules/_io/winconsoleio.c +++ b/Modules/_io/winconsoleio.c @@ -304,18 +304,11 @@ _io__WindowsConsoleIO___init___impl(winconsoleio *self, PyObject *nameobj, if (!d) return -1; - Py_ssize_t length; - name = PyUnicode_AsWideCharString(decodedname, &length); + name = PyUnicode_AsWideCharString(decodedname, NULL); console_type = _PyIO_get_console_type(decodedname); Py_CLEAR(decodedname); if (name == NULL) return -1; - - if (wcslen(name) != length) { - PyMem_Free(name); - PyErr_SetString(PyExc_ValueError, "embedded null character"); - return -1; - } } s = mode; |