From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 12 Jan 2026 16:06:24 +0000 (+0100) Subject: [3.14] gh-143544: Fix possible use-after-free in the JSON decoder when JSONDecodeErro... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=78ea9eb3406781c9f3fc3e216377bd0e38350d05;p=thirdparty%2FPython%2Fcpython.git [3.14] gh-143544: Fix possible use-after-free in the JSON decoder when JSONDecodeError disappears during raising it (GH-143561) (#143733) gh-143544: Fix possible use-after-free in the JSON decoder when JSONDecodeError disappears during raising it (GH-143561) (cherry picked from commit c3157480601499565fd42a8afbdb0207328ac484) Co-authored-by: VanshAgarwal24036 <148854295+VanshAgarwal24036@users.noreply.github.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> --- diff --git a/Modules/_json.c b/Modules/_json.c index 2f82a69a1579..b3959cfe4a11 100644 --- a/Modules/_json.c +++ b/Modules/_json.c @@ -316,11 +316,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