summaryrefslogtreecommitdiff
path: root/pyuno
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-05-26 14:58:59 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-05-26 15:51:56 +0100
commit5bdc28028c6b4959d045e2f52ab852efa947e8f9 (patch)
treefc7b9f5b2bdb695c9ed9f12fd17eb62bedba75f0 /pyuno
parentc6c135930c66d2465dcdfbb34ecb2d1abff735c6 (diff)
coverity#982760 Dereference null return value
Change-Id: I779fa5fa418370dd6c53308943374e981f65ae29
Diffstat (limited to 'pyuno')
-rw-r--r--pyuno/inc/pyuno/pyuno.hxx13
-rw-r--r--pyuno/source/module/pyuno_type.cxx2
2 files changed, 14 insertions, 1 deletions
diff --git a/pyuno/inc/pyuno/pyuno.hxx b/pyuno/inc/pyuno/pyuno.hxx
index da0f8328e50f..77f966222ecd 100644
--- a/pyuno/inc/pyuno/pyuno.hxx
+++ b/pyuno/inc/pyuno/pyuno.hxx
@@ -68,6 +68,13 @@ extern "C" LO_DLLPUBLIC_PYUNO
namespace pyuno
{
+enum __NotNull
+{
+ /** definition of a no acquire enum for ctors
+ */
+ NOT_NULL
+};
+
/** Helper class for keeping references to python objects.
BEWARE: Look up every python function you use to check
whether you get an acquired or not acquired object pointer
@@ -88,6 +95,12 @@ public:
PyRef( PyObject * p, __sal_NoAcquire ) : m( p ) {}
+ PyRef( PyObject * p, __sal_NoAcquire, __NotNull ) : m( p )
+ {
+ if (!m)
+ throw std::bad_alloc();
+ }
+
PyRef( const PyRef &r ) : m( r.get() ) { Py_XINCREF( m ); }
~PyRef() { Py_XDECREF( m ); }
diff --git a/pyuno/source/module/pyuno_type.cxx b/pyuno/source/module/pyuno_type.cxx
index 0d8e63050fd1..5c0e2f30c52c 100644
--- a/pyuno/source/module/pyuno_type.cxx
+++ b/pyuno/source/module/pyuno_type.cxx
@@ -265,7 +265,7 @@ PyObject *PyUNO_Enum_new( const char *enumBase, const char *enumValue, const Run
PyObject* PyUNO_Type_new (const char *typeName , TypeClass t , const Runtime &r )
{
// retrieve type object
- PyRef args( PyTuple_New( 2 ), SAL_NO_ACQUIRE );
+ PyRef args(PyTuple_New( 2 ), SAL_NO_ACQUIRE, NOT_NULL);
PyTuple_SetItem( args.get() , 0 , PyStr_FromString( typeName ) );
PyObject *typeClass = PyUNO_Enum_new( "com.sun.star.uno.TypeClass" , typeClassToString(t), r );