Skip to content

Commit d52f22e

Browse files
committed
gh-129271: Fix reference leak with unicode writer in fast path in the json module
1 parent f10b7b2 commit d52f22e

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Modules/_json.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ scanstring_unicode(PyObject *pystr, Py_ssize_t end, int strict, Py_ssize_t *next
413413
if (c == '"') {
414414
// Fast path for simple case.
415415
if (_PyUnicodeWriter_IsEmpty(writer)) {
416+
PyUnicodeWriter_Discard(writer);
416417
PyObject *ret = PyUnicode_Substring(pystr, end, next);
417418
if (ret == NULL) {
418419
goto bail;

0 commit comments

Comments
 (0)