[pypy-commit] cffi default: Figured out a memory leak in an error case
arigo
pypy.commits at gmail.com
Sun Jun 4 09:06:17 EDT 2017
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r2973:6e1b6c8e1d79
Date: 2017-06-04 15:06 +0200
http://bitbucket.org/cffi/cffi/changeset/6e1b6c8e1d79/
Log: Figured out a memory leak in an error case
diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -4137,7 +4137,10 @@
assert(x->ct_unique_key == NULL);
x->ct_unique_key = key; /* the key will be freed in ctypedescr_dealloc() */
- Py_DECREF(x); /* the 'value' in unique_cache doesn't count as 1 */
+ /* the 'value' in unique_cache doesn't count as 1, but don't use
+ Py_DECREF(x) here because it will confuse debug builds into thinking
+ there was an extra DECREF in total. */
+ ((PyObject *)x)->ob_refcnt--;
return (PyObject *)x;
error:
@@ -6231,6 +6234,7 @@
src = cd->c_data;
itemsize = ctitem->ct_size;
if (itemsize < 0) {
+ Py_DECREF(result);
PyErr_Format(PyExc_ValueError, "'%s' points to items of unknown size",
cd->c_type->ct_name);
return NULL;
More information about the pypy-commit
mailing list