Skip to content

Commit c315748

Browse files
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>
1 parent fe78c1e commit c315748

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Modules/_json.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,11 +423,12 @@ raise_errmsg(const char *msg, PyObject *s, Py_ssize_t end)
423423

424424
PyObject *exc;
425425
exc = PyObject_CallFunction(JSONDecodeError, "zOn", msg, s, end);
426-
Py_DECREF(JSONDecodeError);
427426
if (exc) {
428427
PyErr_SetObject(JSONDecodeError, exc);
429428
Py_DECREF(exc);
430429
}
430+
431+
Py_DECREF(JSONDecodeError);
431432
}
432433

433434
static void

0 commit comments

Comments
 (0)