https://github.com/python/cpython/commit/8b7ebbb43217362f7fb61f6a4cf3f90e3e0c8880
commit: 8b7ebbb43217362f7fb61f6a4cf3f90e3e0c8880
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: vstinner <[email protected]>
date: 2026-01-12T16:02:23Z
summary:

[3.13] gh-143544: Fix possible use-after-free in the JSON decoder when 
JSONDecodeError disappears during raising it (GH-143561) (#143734)

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 
<[email protected]>
Co-authored-by: Bénédikt Tran <[email protected]>

files:
M Modules/_json.c

diff --git a/Modules/_json.c b/Modules/_json.c
index cc41b9ab867a28..afefc71bfbdd9a 100644
--- a/Modules/_json.c
+++ b/Modules/_json.c
@@ -308,11 +308,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

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to