From e8e6eed0bed9db46b71fb79f8582680f8b09191a Mon Sep 17 00:00:00 2001 From: "liujisi@google.com" Date: Tue, 7 Jun 2011 03:38:28 +0000 Subject: [PATCH] Fixed a memory leak in python CPP implementation. --- python/google/protobuf/pyext/python-proto2.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/google/protobuf/pyext/python-proto2.cc b/python/google/protobuf/pyext/python-proto2.cc index f2799e62..181d7e97 100644 --- a/python/google/protobuf/pyext/python-proto2.cc +++ b/python/google/protobuf/pyext/python-proto2.cc @@ -1099,10 +1099,12 @@ static PyObject* CMessage_AssignRepeatedScalar(CMessage* self, PyObject* args) { PyObject* next; while ((next = PyIter_Next(iter)) != NULL) { if (InternalAddRepeatedScalar( - message, cfield_descriptor->descriptor, next) == NULL) { + message, cfield_descriptor->descriptor, next) == NULL) { + Py_DECREF(next); Py_DECREF(iter); return NULL; } + Py_DECREF(next); } Py_DECREF(iter); Py_RETURN_NONE;