https://github.com/python/cpython/commit/71cf3130c6e5dd903837b6871af99156c799fd1e
commit: 71cf3130c6e5dd903837b6871af99156c799fd1e
branch: main
author: pengyu lee <[email protected]>
committer: kumaraditya303 <[email protected]>
date: 2026-05-25T16:12:33+05:30
summary:
gh-150379: fix ref leak in C API monitoring events (#150381)
files:
M Python/instrumentation.c
diff --git a/Python/instrumentation.c b/Python/instrumentation.c
index 51bcbfdb3b6c55..0af2070b5cd983 100644
--- a/Python/instrumentation.c
+++ b/Python/instrumentation.c
@@ -2630,8 +2630,9 @@ capi_call_instrumentation(PyMonitoringState *state,
PyObject *codelike, int32_t
PyErr_SetString(PyExc_ValueError, "offset must be non-negative");
return -1;
}
+ PyObject *offset_obj = NULL;
if (event != PY_MONITORING_EVENT_LINE) {
- PyObject *offset_obj = PyLong_FromLong(offset);
+ offset_obj = PyLong_FromLong(offset);
if (offset_obj == NULL) {
return -1;
}
@@ -2672,6 +2673,7 @@ capi_call_instrumentation(PyMonitoringState *state,
PyObject *codelike, int32_t
}
}
}
+ Py_XDECREF(offset_obj);
return err;
}
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]