Skip to content

Commit 4a7f323

Browse files
gh-143544: Fix use-after-free in _json.raise_errmsg
1 parent 10c61c4 commit 4a7f323

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

Modules/_json.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,14 +415,14 @@ raise_errmsg(const char *msg, PyObject *s, Py_ssize_t end)
415415
{
416416
/* Use JSONDecodeError exception to raise a nice looking ValueError subclass */
417417
_Py_DECLARE_STR(json_decoder, "json.decoder");
418-
419418
PyObject *JSONDecodeError =
420419
PyImport_ImportModuleAttr(&_Py_STR(json_decoder), &_Py_ID(JSONDecodeError));
421420
if (JSONDecodeError == NULL) {
422421
return;
423422
}
424423

425-
PyObject *exc = PyObject_CallFunction(JSONDecodeError, "zOn", msg, s, end);
424+
PyObject *exc;
425+
exc = PyObject_CallFunction(JSONDecodeError, "zOn", msg, s, end);
426426
if (exc) {
427427
PyErr_SetObject(JSONDecodeError, exc);
428428
Py_DECREF(exc);
@@ -431,7 +431,6 @@ raise_errmsg(const char *msg, PyObject *s, Py_ssize_t end)
431431
Py_DECREF(JSONDecodeError);
432432
}
433433

434-
435434
static void
436435
raise_stop_iteration(Py_ssize_t idx)
437436
{

0 commit comments

Comments
 (0)