Skip to content

Commit 71cf313

Browse files
authored
gh-150379: fix ref leak in C API monitoring events (#150381)
1 parent 832afed commit 71cf313

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

Python/instrumentation.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2630,8 +2630,9 @@ capi_call_instrumentation(PyMonitoringState *state, PyObject *codelike, int32_t
26302630
PyErr_SetString(PyExc_ValueError, "offset must be non-negative");
26312631
return -1;
26322632
}
2633+
PyObject *offset_obj = NULL;
26332634
if (event != PY_MONITORING_EVENT_LINE) {
2634-
PyObject *offset_obj = PyLong_FromLong(offset);
2635+
offset_obj = PyLong_FromLong(offset);
26352636
if (offset_obj == NULL) {
26362637
return -1;
26372638
}
@@ -2672,6 +2673,7 @@ capi_call_instrumentation(PyMonitoringState *state, PyObject *codelike, int32_t
26722673
}
26732674
}
26742675
}
2676+
Py_XDECREF(offset_obj);
26752677
return err;
26762678
}
26772679

0 commit comments

Comments
 (0)