From 8d70094e65b4175a5e872f77f225bb875a6b4e38 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Mon, 4 Nov 2024 09:15:23 -0500 Subject: [PATCH] Fix refcounting --- Objects/codeobject.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Objects/codeobject.c b/Objects/codeobject.c index 95584f17cc0af6..8fd17b49cdd996 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -2478,8 +2478,12 @@ _PyCode_ConstantKey(PyObject *op) PyObject *slice_key = PySlice_New(start_key, stop_key, step_key); if (slice_key == NULL) { + Py_DECREF(start_key); + Py_DECREF(stop_key); + Py_DECREF(step_key); return NULL; } + key = PyTuple_Pack(2, slice_key, op); Py_DECREF(slice_key); }