Commit e46335b3 authored by Victor Stinner's avatar Victor Stinner

Issue #18203: Fix _Py_DecodeUTF8_surrogateescape(), use PyMem_RawMalloc() as _Py_char2wchar()

parent e82f3a4e
...@@ -4806,7 +4806,7 @@ onError: ...@@ -4806,7 +4806,7 @@ onError:
used to decode the command line arguments on Mac OS X. used to decode the command line arguments on Mac OS X.
Return a pointer to a newly allocated wide character string (use Return a pointer to a newly allocated wide character string (use
PyMem_Free() to free the memory), or NULL on memory allocation error. */ PyMem_RawFree() to free the memory), or NULL on memory allocation error. */
wchar_t* wchar_t*
_Py_DecodeUTF8_surrogateescape(const char *s, Py_ssize_t size) _Py_DecodeUTF8_surrogateescape(const char *s, Py_ssize_t size)
...@@ -4819,7 +4819,7 @@ _Py_DecodeUTF8_surrogateescape(const char *s, Py_ssize_t size) ...@@ -4819,7 +4819,7 @@ _Py_DecodeUTF8_surrogateescape(const char *s, Py_ssize_t size)
character count */ character count */
if (PY_SSIZE_T_MAX / sizeof(wchar_t) < (size + 1)) if (PY_SSIZE_T_MAX / sizeof(wchar_t) < (size + 1))
return NULL; return NULL;
unicode = PyMem_Malloc((size + 1) * sizeof(wchar_t)); unicode = PyMem_RawMalloc((size + 1) * sizeof(wchar_t));
if (!unicode) if (!unicode)
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment