Skip to content

Commit d4e520e

Browse files
author
benjamin.peterson
committed
fix more possible ref leaks in _json and use Py_CLEAR
git-svn-id: http://svn.python.org/projects/python/trunk@66942 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent d1dcd7e commit d4e520e

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Modules/_json.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ scanstring_str(PyObject *pystr, Py_ssize_t end, char *encoding, int strict)
271271
goto bail;
272272
}
273273
if (PyList_Append(chunks, chunk)) {
274+
Py_DECREF(chunk);
274275
goto bail;
275276
}
276277
Py_DECREF(chunk);
@@ -372,6 +373,7 @@ scanstring_str(PyObject *pystr, Py_ssize_t end, char *encoding, int strict)
372373
goto bail;
373374
}
374375
if (PyList_Append(chunks, chunk)) {
376+
Py_DECREF(chunk);
375377
goto bail;
376378
}
377379
Py_DECREF(chunk);
@@ -381,8 +383,7 @@ scanstring_str(PyObject *pystr, Py_ssize_t end, char *encoding, int strict)
381383
if (rval == NULL) {
382384
goto bail;
383385
}
384-
Py_DECREF(chunks);
385-
chunks = NULL;
386+
Py_CLEAR(chunks);
386387
return Py_BuildValue("(Nn)", rval, end);
387388
bail:
388389
Py_XDECREF(chunks);
@@ -533,6 +534,7 @@ scanstring_unicode(PyObject *pystr, Py_ssize_t end, int strict)
533534
goto bail;
534535
}
535536
if (PyList_Append(chunks, chunk)) {
537+
Py_DECREF(chunk);
536538
goto bail;
537539
}
538540
Py_DECREF(chunk);

0 commit comments

Comments
 (0)