New GitHub issue #119002 from 3xt3r:<br>
<hr>
<pre>
# Crash report
### What happened?
```python
static PyObject *
sys__getframe_impl(PyObject *module, int depth)
/*[clinic end generated code: output=d438776c04d59804 input=c1be8a6464b11ee5]*/
{
PyThreadState *tstate = _PyThreadState_GET();
PyFrameObject *f = PyThreadState_GetFrame(tstate);
if (_PySys_Audit(tstate, "sys._getframe", "O", f) < 0) {
Py_DECREF(f);
return NULL;
}
```
This implemention doesn't take in account case when PyThreadState_GetFrame returns NULL.
If PyThreadState_GetFrame returns a NULL, Py_DECREF will be failed with segfault. This hard to reproduce, but theoretically it can happen.
**Python version**
3.10.14
### CPython versions tested on:
3.10
### Operating systems tested on:
_No response_
### Output from running 'python -VV' on the command line:
_No response_
</pre>
<hr>
<a href="https://github.com/python/cpython/issues/119002">View on GitHub</a>
<p>Labels: type-crash</p>
<p>Assignee: </p>