diff options
author | A. Unique TensorFlower <gardener@tensorflow.org> | 2018-10-08 12:34:00 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-10-08 12:38:14 -0700 |
commit | d3595b1534a855f3d0da35d3f1dd8b5d464b1b70 (patch) | |
tree | d3a7d04b452d882e6001b470666bc3b31923e97d /tensorflow/python/util | |
parent | fb2807c70de107eb55fb6e8fff2bb8a7e4284ea9 (diff) |
Fix a couple of reference leaks
PiperOrigin-RevId: 216230391
Diffstat (limited to 'tensorflow/python/util')
-rw-r--r-- | tensorflow/python/util/util.cc | 8 |
1 files changed, 3 insertions, 5 deletions
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; } |