diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-06-28 06:27:35 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-28 06:27:35 (GMT) |
commit | 0834905d9b61291b1fc5e05a1ffbc69de9c9379f (patch) | |
tree | 456e79426ec816ba7e0a0bef7e94a6f8423b2786 /Include | |
parent | 413c0a92bcc92efe92849fe5e711163da453410b (diff) | |
download | cpython-0834905d9b61291b1fc5e05a1ffbc69de9c9379f.zip cpython-0834905d9b61291b1fc5e05a1ffbc69de9c9379f.tar.gz cpython-0834905d9b61291b1fc5e05a1ffbc69de9c9379f.tar.bz2 |
[3.6] bpo-13617: Reject embedded null characters in wchar* strings. (GH-2302) (#2462)
Based on patch by Victor Stinner.
Add private C API function _PyUnicode_AsUnicode() which is similar to
PyUnicode_AsUnicode(), but checks for null characters..
(cherry picked from commit f7eae0adfcd4c50034281b2c69f461b43b68db84)
Diffstat (limited to 'Include')
-rw-r--r-- | Include/unicodeobject.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h index cec2b7f..f498873 100644 --- a/Include/unicodeobject.h +++ b/Include/unicodeobject.h @@ -752,23 +752,27 @@ PyAPI_FUNC(Py_UCS4*) PyUnicode_AsUCS4( PyAPI_FUNC(Py_UCS4*) PyUnicode_AsUCS4Copy(PyObject *unicode); #endif +#ifndef Py_LIMITED_API /* Return a read-only pointer to the Unicode object's internal Py_UNICODE buffer. If the wchar_t/Py_UNICODE representation is not yet available, this function will calculate it. */ -#ifndef Py_LIMITED_API PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode( PyObject *unicode /* Unicode object */ ); -#endif + +/* Similar to PyUnicode_AsUnicode(), but raises a ValueError if the string + contains null characters. */ +PyAPI_FUNC(const Py_UNICODE *) _PyUnicode_AsUnicode( + PyObject *unicode /* Unicode object */ + ); /* Return a read-only pointer to the Unicode object's internal Py_UNICODE buffer and save the length at size. If the wchar_t/Py_UNICODE representation is not yet available, this function will calculate it. */ -#ifndef Py_LIMITED_API PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicodeAndSize( PyObject *unicode, /* Unicode object */ Py_ssize_t *size /* location where to save the length */ |