diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-01-30 12:01:27 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-01-30 12:01:47 +0100 |
commit | b1de7935b81d95875f625676b7dd6e6b059309e4 (patch) | |
tree | 9540e6eba951b2a1a63860244ba86b61d10a47ac /pyuno | |
parent | 0b20f01a8817867d7657ed2ee29321de9af15843 (diff) |
coverity#983054, reorder code to avoid memory leak
Change-Id: If14160802f77673e3ebe69850e00d0506125969c
Diffstat (limited to 'pyuno')
-rw-r--r-- | pyuno/source/module/pyuno.cxx | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/pyuno/source/module/pyuno.cxx b/pyuno/source/module/pyuno.cxx index be8906172e6c..ece456094291 100644 --- a/pyuno/source/module/pyuno.cxx +++ b/pyuno/source/module/pyuno.cxx @@ -741,36 +741,31 @@ PyObject* PyUNO_new_UNCHECKED ( const Any &targetInterface, const Reference<XSingleServiceFactory> &ssf ) { - PyUNO* self; - Sequence<Any> arguments (1); Reference<XInterface> tmp_interface; - - self = PyObject_New (PyUNO, &PyUNOType); - if (self == NULL) - return NULL; // == error - self->members = new PyUNOInternals(); - - arguments[0] <<= targetInterface; + Reference<XInvocation2> tmp_invocation; { PyThreadDetach antiguard; - tmp_interface = ssf->createInstanceWithArguments (arguments); - - if (!tmp_interface.is ()) - { - Py_INCREF( Py_None ); - return Py_None; - } - - Reference<XInvocation2> tmp_invocation (tmp_interface, UNO_QUERY); - if (!tmp_invocation.is()) { - throw RuntimeException (OUString::createFromAscii ( - "XInvocation2 not implemented, cannot interact with object"), - Reference< XInterface > ()); + Sequence<Any> arguments(1); + arguments[0] <<= targetInterface; + tmp_interface = ssf->createInstanceWithArguments(arguments); + tmp_invocation.set(tmp_interface, UNO_QUERY); + if (!tmp_invocation.is() && tmp_interface.is()) { + throw RuntimeException( + "XInvocation2 not implemented, cannot interact with object", + Reference<XInterface>()); } - - self->members->xInvocation = tmp_invocation; - self->members->wrappedObject = targetInterface; } + if (!tmp_interface.is()) + { + Py_INCREF( Py_None ); + return Py_None; + } + PyUNO* self = PyObject_New (PyUNO, &PyUNOType); + if (self == NULL) + return NULL; // == error + self->members = new PyUNOInternals(); + self->members->xInvocation = tmp_invocation; + self->members->wrappedObject = targetInterface; return (PyObject*) self; } |