mirror of
https://github.com/python/cpython.git
synced 2025-12-10 11:00:14 +00:00
Closes #21780: make the unicodedata module "ssize_t clean" for parsing parameters
This commit is contained in:
parent
2e57b4e488
commit
65a3144e54
1 changed files with 8 additions and 2 deletions
|
|
@ -13,6 +13,8 @@
|
||||||
|
|
||||||
------------------------------------------------------------------------ */
|
------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
#define PY_SSIZE_T_CLEAN
|
||||||
|
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
#include "ucnhash.h"
|
#include "ucnhash.h"
|
||||||
#include "structmember.h"
|
#include "structmember.h"
|
||||||
|
|
@ -1271,12 +1273,16 @@ unicodedata_lookup(PyObject* self, PyObject* args)
|
||||||
Py_UCS4 code;
|
Py_UCS4 code;
|
||||||
|
|
||||||
char* name;
|
char* name;
|
||||||
int namelen;
|
Py_ssize_t namelen;
|
||||||
unsigned int index;
|
unsigned int index;
|
||||||
if (!PyArg_ParseTuple(args, "s#:lookup", &name, &namelen))
|
if (!PyArg_ParseTuple(args, "s#:lookup", &name, &namelen))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
if (namelen > INT_MAX) {
|
||||||
|
PyErr_SetString(PyExc_KeyError, "name too long");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!_getcode(self, name, namelen, &code, 1)) {
|
if (!_getcode(self, name, (int)namelen, &code, 1)) {
|
||||||
PyErr_Format(PyExc_KeyError, "undefined character name '%s'", name);
|
PyErr_Format(PyExc_KeyError, "undefined character name '%s'", name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue