Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Lines 1251 to 1285 in4d8959b
| staticint | |
| positional_only_passed_as_keyword(PyThreadState*tstate,PyCodeObject*co, | |
| Py_ssize_tkwcount,PyObject*kwnames, | |
| PyObject*qualname) | |
| { | |
| intposonly_conflicts=0; | |
| PyObject*posonly_names=PyList_New(0); | |
| for(intk=0;k<co->co_posonlyargcount;k++){ | |
| PyObject*posonly_name=PyTuple_GET_ITEM(co->co_localsplusnames,k); | |
| for (intk2=0;k2<kwcount;k2++){ | |
| /* Compare the pointers first and fallback to PyObject_RichCompareBool*/ | |
| PyObject*kwname=PyTuple_GET_ITEM(kwnames,k2); | |
| if (kwname==posonly_name){ | |
| if(PyList_Append(posonly_names,kwname)!=0) { | |
| gotofail; | |
| } | |
| posonly_conflicts++; | |
| continue; | |
| } | |
| intcmp=PyObject_RichCompareBool(posonly_name,kwname,Py_EQ); | |
| if (cmp>0) { | |
| if(PyList_Append(posonly_names,kwname)!=0) { | |
| gotofail; | |
| } | |
| posonly_conflicts++; | |
| }elseif (cmp<0) { | |
| gotofail; | |
| } | |
| } | |
| } |
This implemention doesn't take in account case whenPyList_New returnsNULL.
IfPyList_New(0) returns aNULL,PyList_Append will be failed with segfault, cause ofPy_TYPE, which will try to reach outob_type. of(PyObject *) NULL.
This hard to reproduce, because the only wayPyList_New can error, if it is runs out of memory, but theoretically it can happen.