Skip to content

Commit 06c9e27

Browse files
authored
[mypyc] Release boxed operands in tagged true division (#21246)
Found by @devdanzin
1 parent 7fb17fd commit 06c9e27

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

mypyc/lib-rt/int_ops.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,9 +590,15 @@ double CPyTagged_TrueDivide(CPyTagged x, CPyTagged y) {
590590
PyObject *yo = CPyTagged_AsObject(y);
591591
PyObject *result = PyNumber_TrueDivide(xo, yo);
592592
if (result == NULL) {
593+
Py_DECREF(xo);
594+
Py_DECREF(yo);
593595
return CPY_FLOAT_ERROR;
594596
}
595-
return PyFloat_AsDouble(result);
597+
double value = PyFloat_AsDouble(result);
598+
Py_DECREF(xo);
599+
Py_DECREF(yo);
600+
Py_DECREF(result);
601+
return value;
596602
}
597603
return 1.0;
598604
}

0 commit comments

Comments
 (0)