[3.14] gh-146092: Fix error handling in _BINARY_OP_ADD_FLOAT opcode (#146119)

Fix error handling in _PyFloat_FromDouble_ConsumeInputs() used by
_BINARY_OP_ADD_FLOAT, _BINARY_OP_SUBTRACT_FLOAT and
_BINARY_OP_MULTIPLY_FLOAT opcodes. PyStackRef_FromPyObjectSteal()
must not be called with a NULL pointer.

Fix also _BINARY_OP_INPLACE_ADD_UNICODE opcode.
This commit is contained in:
Victor Stinner 2026-03-19 12:14:33 +01:00 committed by GitHub
parent cfdc5e86dd
commit 7f29c1d0da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 18 additions and 11 deletions

View file

@ -793,9 +793,12 @@ dummy_func(
PyObject *temp = PyStackRef_AsPyObjectSteal(*target_local);
PyObject *right_o = PyStackRef_AsPyObjectSteal(right);
PyUnicode_Append(&temp, right_o);
*target_local = PyStackRef_FromPyObjectSteal(temp);
Py_DECREF(right_o);
ERROR_IF(PyStackRef_IsNull(*target_local));
if (temp == NULL) {
*target_local = PyStackRef_NULL;
ERROR_IF(true);
}
*target_local = PyStackRef_FromPyObjectSteal(temp);
#if TIER_ONE
// The STORE_FAST is already done. This is done here in tier one,
// and during trace projection in tier two:

View file

@ -1131,14 +1131,13 @@
assert(WITHIN_STACK_BOUNDS());
_PyFrame_SetStackPointer(frame, stack_pointer);
PyUnicode_Append(&temp, right_o);
stack_pointer = _PyFrame_GetStackPointer(frame);
*target_local = PyStackRef_FromPyObjectSteal(temp);
_PyFrame_SetStackPointer(frame, stack_pointer);
Py_DECREF(right_o);
stack_pointer = _PyFrame_GetStackPointer(frame);
if (PyStackRef_IsNull(*target_local)) {
if (temp == NULL) {
*target_local = PyStackRef_NULL;
JUMP_TO_ERROR();
}
*target_local = PyStackRef_FromPyObjectSteal(temp);
#if TIER_ONE
assert(next_instr->op.code == STORE_FAST);

View file

@ -392,14 +392,13 @@
assert(WITHIN_STACK_BOUNDS());
_PyFrame_SetStackPointer(frame, stack_pointer);
PyUnicode_Append(&temp, right_o);
stack_pointer = _PyFrame_GetStackPointer(frame);
*target_local = PyStackRef_FromPyObjectSteal(temp);
_PyFrame_SetStackPointer(frame, stack_pointer);
Py_DECREF(right_o);
stack_pointer = _PyFrame_GetStackPointer(frame);
if (PyStackRef_IsNull(*target_local)) {
if (temp == NULL) {
*target_local = PyStackRef_NULL;
JUMP_TO_LABEL(error);
}
*target_local = PyStackRef_FromPyObjectSteal(temp);
#if TIER_ONE
assert(next_instr->op.code == STORE_FAST);