mirror of
https://github.com/python/cpython.git
synced 2025-12-15 21:44:50 +00:00
Issue #18408: PyObject_GC_NewVar() now raises SystemError exception if nitems
is negative
This commit is contained in:
parent
c1eb26cd2f
commit
5d1866c78a
1 changed files with 9 additions and 2 deletions
|
|
@ -1689,8 +1689,15 @@ _PyObject_GC_New(PyTypeObject *tp)
|
|||
PyVarObject *
|
||||
_PyObject_GC_NewVar(PyTypeObject *tp, Py_ssize_t nitems)
|
||||
{
|
||||
const size_t size = _PyObject_VAR_SIZE(tp, nitems);
|
||||
PyVarObject *op = (PyVarObject *) _PyObject_GC_Malloc(size);
|
||||
size_t size;
|
||||
PyVarObject *op;
|
||||
|
||||
if (nitems < 0) {
|
||||
PyErr_BadInternalCall();
|
||||
return NULL;
|
||||
}
|
||||
size = _PyObject_VAR_SIZE(tp, nitems);
|
||||
op = (PyVarObject *) _PyObject_GC_Malloc(size);
|
||||
if (op != NULL)
|
||||
op = PyObject_INIT_VAR(op, tp, nitems);
|
||||
return op;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue