From 5bdc28028c6b4959d045e2f52ab852efa947e8f9 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 26 May 2014 14:58:59 +0100 Subject: coverity#982760 Dereference null return value Change-Id: I779fa5fa418370dd6c53308943374e981f65ae29 --- pyuno/inc/pyuno/pyuno.hxx | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'pyuno/inc') 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 ); } -- cgit