Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2f366ca

Browse files
committed
Add an extra byte for null in case we ever get very long unicode names.
1 parent bd2ffa5 commit 2f366ca

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Modules/unicodedata.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,8 +1041,8 @@ _cmpname(PyObject *self, int code, const char* name, int namelen)
10411041
{
10421042
/* check if code corresponds to the given name */
10431043
int i;
1044-
char buffer[NAME_MAXLEN];
1045-
if (!_getucname(self, code, buffer, sizeof(buffer), 1))
1044+
char buffer[NAME_MAXLEN+1];
1045+
if (!_getucname(self, code, buffer, NAME_MAXLEN, 1))
10461046
return 0;
10471047
for (i = 0; i < namelen; i++) {
10481048
if (Py_TOUPPER(Py_CHARMASK(name[i])) != buffer[i])
@@ -1195,10 +1195,10 @@ static PyObject *
11951195
unicodedata_UCD_name_impl(PyObject *self, int chr, PyObject *default_value)
11961196
/*[clinic end generated code: output=6bbb37a326407707 input=3e0367f534de56d9]*/
11971197
{
1198-
char name[NAME_MAXLEN];
1198+
char name[NAME_MAXLEN+1];
11991199
Py_UCS4 c = (Py_UCS4)chr;
12001200

1201-
if (!_getucname(self, c, name, sizeof(name), 0)) {
1201+
if (!_getucname(self, c, name, NAME_MAXLEN, 0)) {
12021202
if (default_value == NULL) {
12031203
PyErr_SetString(PyExc_ValueError, "no such name");
12041204
return NULL;

0 commit comments

Comments
 (0)