summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2016-01-07 10:39:57 -0800
committerMark Spruiell <mes@zeroc.com>2016-01-07 10:39:57 -0800
commitda5474d110c9984a882766922d5d9201c44c2a81 (patch)
tree58b6433face64824af4e8e833cc747d9363fcb88
parentBackport fix for ICE-5678 to 3.4.2 (diff)
downloadice-da5474d110c9984a882766922d5d9201c44c2a81.tar.bz2
ice-da5474d110c9984a882766922d5d9201c44c2a81.tar.xz
ice-da5474d110c9984a882766922d5d9201c44c2a81.zip
ICE-6955 - refcount bug in Python blobject API3.4
-rw-r--r--py/modules/IcePy/Operation.cpp8
-rw-r--r--py/modules/IcePy/Util.h18
2 files changed, 20 insertions, 6 deletions
diff --git a/py/modules/IcePy/Operation.cpp b/py/modules/IcePy/Operation.cpp
index b8dfed5e909..73d26572520 100644
--- a/py/modules/IcePy/Operation.cpp
+++ b/py/modules/IcePy/Operation.cpp
@@ -2320,7 +2320,7 @@ IcePy::SyncBlobjectInvocation::invoke(PyObject* args, PyObject* /* kwds */)
throwPythonException();
}
- if(PyTuple_SET_ITEM(result.get(), 0, ok ? getTrue() : getFalse()) < 0)
+ if(PyTuple_SET_ITEM(result.get(), 0, ok ? incTrue() : incFalse()) < 0)
{
throwPythonException();
}
@@ -2567,7 +2567,7 @@ IcePy::AsyncBlobjectInvocation::end(const Ice::ObjectPrx& proxy, const Ice::Asyn
return 0;
}
- if(PyTuple_SET_ITEM(args.get(), 0, ok ? getTrue() : getFalse()) < 0)
+ if(PyTuple_SET_ITEM(args.get(), 0, ok ? incTrue() : incFalse()) < 0)
{
return 0;
}
@@ -2633,7 +2633,7 @@ IcePy::AsyncBlobjectInvocation::response(bool ok, const pair<const Ice::Byte*, c
return;
}
- if(PyTuple_SET_ITEM(args.get(), 0, ok ? getTrue() : getFalse()) < 0)
+ if(PyTuple_SET_ITEM(args.get(), 0, ok ? incTrue() : incFalse()) < 0)
{
assert(PyErr_Occurred());
PyErr_Print();
@@ -2813,7 +2813,7 @@ IcePy::OldAsyncBlobjectInvocation::response(bool ok, const pair<const Ice::Byte*
return;
}
- if(PyTuple_SET_ITEM(args.get(), 0, ok ? getTrue() : getFalse()) < 0)
+ if(PyTuple_SET_ITEM(args.get(), 0, ok ? incTrue() : incFalse()) < 0)
{
assert(PyErr_Occurred());
PyErr_Print();
diff --git a/py/modules/IcePy/Util.h b/py/modules/IcePy/Util.h
index 5520c1f07d9..9670b134f84 100644
--- a/py/modules/IcePy/Util.h
+++ b/py/modules/IcePy/Util.h
@@ -23,8 +23,8 @@
// instead of the standard ones in order to avoid GCC warnings about
// strict aliasing and type punning.
//
-#define PyRETURN_FALSE return Py_INCREF(getFalse()), getFalse()
-#define PyRETURN_TRUE return Py_INCREF(getTrue()), getTrue()
+#define PyRETURN_FALSE return incFalse()
+#define PyRETURN_TRUE return incTrue()
#define PyRETURN_BOOL(b) if(b) PyRETURN_TRUE; else PyRETURN_FALSE
@@ -49,6 +49,20 @@ inline PyObject* getTrue()
return reinterpret_cast<PyObject*>(i);
}
+inline PyObject* incFalse()
+{
+ PyObject* f = getFalse();
+ Py_INCREF(f);
+ return f;
+}
+
+inline PyObject* incTrue()
+{
+ PyObject* t = getTrue();
+ Py_INCREF(t);
+ return t;
+}
+
inline PyObject* createString(const std::string& str)
{
return PyString_FromStringAndSize(str.c_str(), static_cast<Py_ssize_t>(str.size()));