Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
gh-146092: Fix error handling in _BINARY_OP_ADD_FLOAT opcode
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.
  • Loading branch information
vstinner committed Mar 18, 2026
commit 3bd1e9db2ae21cfc12e417b461f44d4cfc50cb89
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Handle properly memory allocation failures on float operations in the
bytecode opcodes. Patch by Victor Stinner.
6 changes: 5 additions & 1 deletion Objects/floatobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,11 @@ _PyStackRef _PyFloat_FromDouble_ConsumeInputs(_PyStackRef left, _PyStackRef righ
{
PyStackRef_CLOSE_SPECIALIZED(left, _PyFloat_ExactDealloc);
PyStackRef_CLOSE_SPECIALIZED(right, _PyFloat_ExactDealloc);
return PyStackRef_FromPyObjectSteal(PyFloat_FromDouble(value));
PyObject *obj = PyFloat_FromDouble(value);
if (obj == NULL) {
return PyStackRef_NULL;
}
return PyStackRef_FromPyObjectSteal(obj);
}

static PyObject *
Expand Down
Loading