[Python-checkins] cpython (2.7): Issue #13019: Fix potential reference leaks in bytearray.extend().
antoine.pitrou
python-checkins at python.org
Sun Apr 1 16:17:11 CEST 2012
http://hg.python.org/cpython/rev/d3a82a26c705
changeset: 76049:d3a82a26c705
branch: 2.7
parent: 76036:3623c3e6c049
user: Antoine Pitrou <solipsis at pitrou.net>
date: Sun Apr 01 16:05:46 2012 +0200
summary:
Issue #13019: Fix potential reference leaks in bytearray.extend().
Patch by Suman Saha.
files:
Misc/NEWS | 3 +++
Objects/bytearrayobject.c | 8 ++++++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -9,6 +9,9 @@
Core and Builtins
-----------------
+- Issue #13019: Fix potential reference leaks in bytearray.extend(). Patch
+ by Suman Saha.
+
- Issue #14378: Fix compiling ast.ImportFrom nodes with a "__future__" string as
the module name that was not interned.
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -2296,8 +2296,10 @@
}
bytearray_obj = PyByteArray_FromStringAndSize(NULL, buf_size);
- if (bytearray_obj == NULL)
+ if (bytearray_obj == NULL) {
+ Py_DECREF(it);
return NULL;
+ }
buf = PyByteArray_AS_STRING(bytearray_obj);
while ((item = PyIter_Next(it)) != NULL) {
@@ -2330,8 +2332,10 @@
return NULL;
}
- if (bytearray_setslice(self, Py_SIZE(self), Py_SIZE(self), bytearray_obj) == -1)
+ if (bytearray_setslice(self, Py_SIZE(self), Py_SIZE(self), bytearray_obj) == -1) {
+ Py_DECREF(bytearray_obj);
return NULL;
+ }
Py_DECREF(bytearray_obj);
Py_RETURN_NONE;
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list