aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-10-08 12:34:00 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-10-08 12:38:14 -0700
commitd3595b1534a855f3d0da35d3f1dd8b5d464b1b70 (patch)
treed3a7d04b452d882e6001b470666bc3b31923e97d /tensorflow/python
parentfb2807c70de107eb55fb6e8fff2bb8a7e4284ea9 (diff)
Fix a couple of reference leaks
PiperOrigin-RevId: 216230391
Diffstat (limited to 'tensorflow/python')
-rwxr-xr-xtensorflow/python/pywrap_tfe.i1
-rw-r--r--tensorflow/python/util/util.cc8
2 files changed, 4 insertions, 5 deletions
diff --git a/tensorflow/python/pywrap_tfe.i b/tensorflow/python/pywrap_tfe.i
index 61e0abbfcb..adbce95c6f 100755
--- a/tensorflow/python/pywrap_tfe.i
+++ b/tensorflow/python/pywrap_tfe.i
@@ -209,6 +209,7 @@ limitations under the License.
SWIG_fail;
} else {
int num_outputs = $1->size();
+ Py_CLEAR($result);
$result = PyList_New(num_outputs);
for (int i = 0; i < num_outputs; ++i) {
PyObject *output;
diff --git a/tensorflow/python/util/util.cc b/tensorflow/python/util/util.cc
index 7b3e618e84..11eb9ce947 100644
--- a/tensorflow/python/util/util.cc
+++ b/tensorflow/python/util/util.cc
@@ -825,18 +825,16 @@ PyObject* IsNamedtuple(PyObject* o, bool strict) {
}
PyObject* SameNamedtuples(PyObject* o1, PyObject* o2) {
- PyObject* f1 = PyObject_GetAttrString(o1, "_fields");
- PyObject* f2 = PyObject_GetAttrString(o2, "_fields");
+ Safe_PyObjectPtr f1 = make_safe(PyObject_GetAttrString(o1, "_fields"));
+ Safe_PyObjectPtr f2 = make_safe(PyObject_GetAttrString(o2, "_fields"));
if (f1 == nullptr || f2 == nullptr) {
- Py_XDECREF(f1);
- Py_XDECREF(f2);
PyErr_SetString(
PyExc_RuntimeError,
"Expected namedtuple-like objects (that have _fields attr)");
return nullptr;
}
- if (PyObject_RichCompareBool(f1, f2, Py_NE)) {
+ if (PyObject_RichCompareBool(f1.get(), f2.get(), Py_NE)) {
Py_RETURN_FALSE;
}