summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2016-01-07 11:00:46 -0800
committerMark Spruiell <mes@zeroc.com>2016-01-07 11:00:46 -0800
commitb1d50d858f2d8f49a8f543adf0a47b94ae6f3864 (patch)
treed0cf9fd67bfeb91feb8553b279cd2316c0f67df0 /python
parentUpdate Twitter account in CONTRIBUTING.md (diff)
downloadice-b1d50d858f2d8f49a8f543adf0a47b94ae6f3864.tar.bz2
ice-b1d50d858f2d8f49a8f543adf0a47b94ae6f3864.tar.xz
ice-b1d50d858f2d8f49a8f543adf0a47b94ae6f3864.zip
ICE-6955 - refcount bug in Python blobject API
Diffstat (limited to 'python')
-rw-r--r--python/modules/IcePy/Operation.cpp8
-rw-r--r--python/modules/IcePy/Util.h18
2 files changed, 20 insertions, 6 deletions
diff --git a/python/modules/IcePy/Operation.cpp b/python/modules/IcePy/Operation.cpp
index 5ca673898f4..42cb836fa9b 100644
--- a/python/modules/IcePy/Operation.cpp
+++ b/python/modules/IcePy/Operation.cpp
@@ -2532,7 +2532,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();
}
@@ -2813,7 +2813,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;
}
@@ -2896,7 +2896,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();
@@ -3112,7 +3112,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/python/modules/IcePy/Util.h b/python/modules/IcePy/Util.h
index 94f8d1b813d..5732a9d10df 100644
--- a/python/modules/IcePy/Util.h
+++ b/python/modules/IcePy/Util.h
@@ -20,8 +20,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
@@ -56,6 +56,20 @@ inline PyObject* getTrue()
#endif
}
+inline PyObject* incFalse()
+{
+ PyObject* f = getFalse();
+ Py_INCREF(f);
+ return f;
+}
+
+inline PyObject* incTrue()
+{
+ PyObject* t = getTrue();
+ Py_INCREF(t);
+ return t;
+}
+
//
// Create a string object.
//