From: VanshAgarwal24036 <148854295+VanshAgarwal24036@users.noreply.github.com> Date: Mon, 12 Jan 2026 15:39:32 +0000 (+0530) Subject: gh-143544: Fix possible use-after-free in the JSON decoder when JSONDecodeError disap... X-Git-Tag: v3.15.0a5~11^2~26 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c3157480601499565fd42a8afbdb0207328ac484;p=thirdparty%2FPython%2Fcpython.git gh-143544: Fix possible use-after-free in the JSON decoder when JSONDecodeError disappears during raising it (#143561) Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> --- diff --git a/Modules/_json.c b/Modules/_json.c index 14714d4b3465..78a85496575a 100644 --- a/Modules/_json.c +++ b/Modules/_json.c @@ -423,11 +423,12 @@ raise_errmsg(const char *msg, PyObject *s, Py_ssize_t end) PyObject *exc; exc = PyObject_CallFunction(JSONDecodeError, "zOn", msg, s, end); - Py_DECREF(JSONDecodeError); if (exc) { PyErr_SetObject(JSONDecodeError, exc); Py_DECREF(exc); } + + Py_DECREF(JSONDecodeError); } static void