]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-143544: Fix possible use-after-free in the JSON decoder when JSONDecodeError disap...
authorVanshAgarwal24036 <148854295+VanshAgarwal24036@users.noreply.github.com>
Mon, 12 Jan 2026 15:39:32 +0000 (21:09 +0530)
committerGitHub <noreply@github.com>
Mon, 12 Jan 2026 15:39:32 +0000 (16:39 +0100)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Modules/_json.c

index 14714d4b346546d86b874c8d962b43c94d0233da..78a85496575a2cf94be4ace09b6fcb78bd7a4efc 100644 (file)
@@ -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