summaryrefslogtreecommitdiffstats
path: root/Modules/unicodedata.c
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2016-09-23 18:21:20 (GMT)
committerChristian Heimes <christian@python.org>2016-09-23 18:21:20 (GMT)
commit0202c347bc54c8a9a54e990c8f1fd4ce380b85e7 (patch)
treee9d0c84d29ff6ac645014410471e5b80430796bc /Modules/unicodedata.c
parente370409cb11941fb27b0c47d698961ec16f3b512 (diff)
parent2f366cab48ef60d947949f15983dd660f1a14462 (diff)
downloadcpython-0202c347bc54c8a9a54e990c8f1fd4ce380b85e7.zip
cpython-0202c347bc54c8a9a54e990c8f1fd4ce380b85e7.tar.gz
cpython-0202c347bc54c8a9a54e990c8f1fd4ce380b85e7.tar.bz2
Add an extra byte for null in case we ever get very long unicode names.
Diffstat (limited to 'Modules/unicodedata.c')
-rw-r--r--Modules/unicodedata.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c
index c86fe23..9e71e01 100644
--- a/Modules/unicodedata.c
+++ b/Modules/unicodedata.c
@@ -1044,8 +1044,8 @@ _cmpname(PyObject *self, int code, const char* name, int namelen)
{
/* check if code corresponds to the given name */
int i;
- char buffer[NAME_MAXLEN];
- if (!_getucname(self, code, buffer, sizeof(buffer), 1))
+ char buffer[NAME_MAXLEN+1];
+ if (!_getucname(self, code, buffer, NAME_MAXLEN, 1))
return 0;
for (i = 0; i < namelen; i++) {
if (Py_TOUPPER(Py_CHARMASK(name[i])) != buffer[i])
@@ -1198,10 +1198,10 @@ static PyObject *
unicodedata_UCD_name_impl(PyObject *self, int chr, PyObject *default_value)
/*[clinic end generated code: output=6bbb37a326407707 input=3e0367f534de56d9]*/
{
- char name[NAME_MAXLEN];
+ char name[NAME_MAXLEN+1];
Py_UCS4 c = (Py_UCS4)chr;
- if (!_getucname(self, c, name, sizeof(name), 0)) {
+ if (!_getucname(self, c, name, NAME_MAXLEN, 0)) {
if (default_value == NULL) {
PyErr_SetString(PyExc_ValueError, "no such name");
return NULL;