Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ceval.c:positional_only_passed_as_keyword can be failed with segfault #101967

Closed
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)type-crashA hard crash of the interpreter, possibly with a core dump
@Eclips4

Description

@Eclips4

cpython/Python/ceval.c

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.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-crashA hard crash of the interpreter, possibly with a core dump

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp