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

Skip to content

Commit 0202c34

Browse files
committed
Add an extra byte for null in case we ever get very long unicode names.
2 parents e370409 + 2f366ca commit 0202c34

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
@@ -1044,8 +1044,8 @@ _cmpname(PyObject *self, int code, const char* name, int namelen)
10441044
{
10451045
/* check if code corresponds to the given name */
10461046
int i;
1047-
char buffer[NAME_MAXLEN];
1048-
if (!_getucname(self, code, buffer, sizeof(buffer), 1))
1047+
char buffer[NAME_MAXLEN+1];
1048+
if (!_getucname(self, code, buffer, NAME_MAXLEN, 1))
10491049
return 0;
10501050
for (i = 0; i < namelen; i++) {
10511051
if (Py_TOUPPER(Py_CHARMASK(name[i])) != buffer[i])
@@ -1198,10 +1198,10 @@ static PyObject *
11981198
unicodedata_UCD_name_impl(PyObject *self, int chr, PyObject *default_value)
11991199
/*[clinic end generated code: output=6bbb37a326407707 input=3e0367f534de56d9]*/
12001200
{
1201-
char name[NAME_MAXLEN];
1201+
char name[NAME_MAXLEN+1];
12021202
Py_UCS4 c = (Py_UCS4)chr;
12031203

1204-
if (!_getucname(self, c, name, sizeof(name), 0)) {
1204+
if (!_getucname(self, c, name, NAME_MAXLEN, 0)) {
12051205
if (default_value == NULL) {
12061206
PyErr_SetString(PyExc_ValueError, "no such name");
12071207
return NULL;

0 commit comments

Comments
 (0)