From 7acc3dd2ca1676a365857ba72ac6ddb29f219e3b Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 27 May 2024 12:25:11 -0400 Subject: [PATCH] fix: handle NULL correctly --- include/pybind11/pybind11.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index 1b890615e4..92ed573a0b 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -2780,7 +2780,7 @@ get_type_override(const void *this_ptr, const type_info *this_type, const char * PyObject *locals = PyEval_GetFrameLocals(); # else PyObject *locals = PyEval_GetLocals(); - Py_INCREF(locals); + Py_XINCREF(locals); # endif if (locals != nullptr) { # if PY_VERSION_HEX >= 0x030b0000