mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-117139: Fix a few _PyStackRef
related bugs (#122831)
`BUILD_SET` should use a borrow instead of a steal. The cleanup in `_DO_CALL` `CONVERSION_FAILED` was incorrect. Co-authored-by: Ken Jin <kenjin@python.org>
This commit is contained in:
parent
be90648fb2
commit
736fe4d23e
3 changed files with 14 additions and 16 deletions
|
@ -1714,11 +1714,10 @@ dummy_func(
|
|||
}
|
||||
int err = 0;
|
||||
for (int i = 0; i < oparg; i++) {
|
||||
PyObject *item = PyStackRef_AsPyObjectSteal(values[i]);
|
||||
if (err == 0) {
|
||||
err = PySet_Add(set_o, item);
|
||||
err = PySet_Add(set_o, PyStackRef_AsPyObjectBorrow(values[i]));
|
||||
}
|
||||
Py_DECREF(item);
|
||||
PyStackRef_CLOSE(values[i]);
|
||||
}
|
||||
if (err != 0) {
|
||||
Py_DECREF(set_o);
|
||||
|
@ -3235,7 +3234,10 @@ dummy_func(
|
|||
/* Callable is not a normal Python function */
|
||||
STACKREFS_TO_PYOBJECTS(args, total_args, args_o);
|
||||
if (CONVERSION_FAILED(args_o)) {
|
||||
DECREF_INPUTS();
|
||||
PyStackRef_CLOSE(callable);
|
||||
for (int i = 0; i < total_args; i++) {
|
||||
PyStackRef_CLOSE(args[i]);
|
||||
}
|
||||
ERROR_IF(true, error);
|
||||
}
|
||||
PyObject *res_o = PyObject_Vectorcall(
|
||||
|
|
5
Python/executor_cases.c.h
generated
5
Python/executor_cases.c.h
generated
|
@ -1957,11 +1957,10 @@
|
|||
}
|
||||
int err = 0;
|
||||
for (int i = 0; i < oparg; i++) {
|
||||
PyObject *item = PyStackRef_AsPyObjectSteal(values[i]);
|
||||
if (err == 0) {
|
||||
err = PySet_Add(set_o, item);
|
||||
err = PySet_Add(set_o, PyStackRef_AsPyObjectBorrow(values[i]));
|
||||
}
|
||||
Py_DECREF(item);
|
||||
PyStackRef_CLOSE(values[i]);
|
||||
}
|
||||
if (err != 0) {
|
||||
Py_DECREF(set_o);
|
||||
|
|
15
Python/generated_cases.c.h
generated
15
Python/generated_cases.c.h
generated
|
@ -714,11 +714,10 @@
|
|||
}
|
||||
int err = 0;
|
||||
for (int i = 0; i < oparg; i++) {
|
||||
PyObject *item = PyStackRef_AsPyObjectSteal(values[i]);
|
||||
if (err == 0) {
|
||||
err = PySet_Add(set_o, item);
|
||||
err = PySet_Add(set_o, PyStackRef_AsPyObjectBorrow(values[i]));
|
||||
}
|
||||
Py_DECREF(item);
|
||||
PyStackRef_CLOSE(values[i]);
|
||||
}
|
||||
if (err != 0) {
|
||||
Py_DECREF(set_o);
|
||||
|
@ -917,9 +916,8 @@
|
|||
STACKREFS_TO_PYOBJECTS(args, total_args, args_o);
|
||||
if (CONVERSION_FAILED(args_o)) {
|
||||
PyStackRef_CLOSE(callable);
|
||||
PyStackRef_CLOSE(self_or_null);
|
||||
for (int _i = oparg; --_i >= 0;) {
|
||||
PyStackRef_CLOSE(args[_i]);
|
||||
for (int i = 0; i < total_args; i++) {
|
||||
PyStackRef_CLOSE(args[i]);
|
||||
}
|
||||
if (true) {
|
||||
stack_pointer += -2 - oparg;
|
||||
|
@ -3705,9 +3703,8 @@
|
|||
STACKREFS_TO_PYOBJECTS(args, total_args, args_o);
|
||||
if (CONVERSION_FAILED(args_o)) {
|
||||
PyStackRef_CLOSE(callable);
|
||||
PyStackRef_CLOSE(self_or_null);
|
||||
for (int _i = oparg; --_i >= 0;) {
|
||||
PyStackRef_CLOSE(args[_i]);
|
||||
for (int i = 0; i < total_args; i++) {
|
||||
PyStackRef_CLOSE(args[i]);
|
||||
}
|
||||
if (true) {
|
||||
stack_pointer += -2 - oparg;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue