Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8e8c215

Browse files
committed
Merged revisions 66938,66942 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r66938 | benjamin.peterson | 2008-10-16 16:27:54 -0500 (Thu, 16 Oct 2008) | 1 line fix possible ref leak ........ r66942 | benjamin.peterson | 2008-10-16 16:48:06 -0500 (Thu, 16 Oct 2008) | 1 line fix more possible ref leaks in _json and use Py_CLEAR ........
1 parent a13d475 commit 8e8c215

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

Modules/_json.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ scanstring_str(PyObject *pystr, Py_ssize_t end, char *encoding, int strict)
276276
goto bail;
277277
}
278278
if (PyList_Append(chunks, chunk)) {
279+
Py_DECREF(chunk);
279280
goto bail;
280281
}
281282
Py_DECREF(chunk);
@@ -377,6 +378,7 @@ scanstring_str(PyObject *pystr, Py_ssize_t end, char *encoding, int strict)
377378
goto bail;
378379
}
379380
if (PyList_Append(chunks, chunk)) {
381+
Py_DECREF(chunk);
380382
goto bail;
381383
}
382384
Py_DECREF(chunk);
@@ -386,8 +388,7 @@ scanstring_str(PyObject *pystr, Py_ssize_t end, char *encoding, int strict)
386388
if (rval == NULL) {
387389
goto bail;
388390
}
389-
Py_DECREF(chunks);
390-
chunks = NULL;
391+
Py_CLEAR(chunks);
391392
return Py_BuildValue("(Nn)", rval, end);
392393
bail:
393394
Py_XDECREF(chunks);
@@ -436,6 +437,7 @@ scanstring_unicode(PyObject *pystr, Py_ssize_t end, int strict)
436437
goto bail;
437438
}
438439
if (PyList_Append(chunks, chunk)) {
440+
Py_DECREF(chunk);
439441
goto bail;
440442
}
441443
Py_DECREF(chunk);
@@ -537,6 +539,7 @@ scanstring_unicode(PyObject *pystr, Py_ssize_t end, int strict)
537539
goto bail;
538540
}
539541
if (PyList_Append(chunks, chunk)) {
542+
Py_DECREF(chunk);
540543
goto bail;
541544
}
542545
Py_DECREF(chunk);
@@ -546,8 +549,7 @@ scanstring_unicode(PyObject *pystr, Py_ssize_t end, int strict)
546549
if (rval == NULL) {
547550
goto bail;
548551
}
549-
Py_DECREF(chunks);
550-
chunks = NULL;
552+
Py_CLEAR(chunks);
551553
return Py_BuildValue("(Nn)", rval, end);
552554
bail:
553555
Py_XDECREF(chunks);

0 commit comments

Comments
 (0)