pyuno/source/module/pyuno.cxx | 45 ++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 25 deletions(-)
New commits: commit b1de7935b81d95875f625676b7dd6e6b059309e4 Author: Stephan Bergmann <sberg...@redhat.com> Date: Thu Jan 30 12:01:27 2014 +0100 coverity#983054, reorder code to avoid memory leak Change-Id: If14160802f77673e3ebe69850e00d0506125969c diff --git a/pyuno/source/module/pyuno.cxx b/pyuno/source/module/pyuno.cxx index be89061..ece4560 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; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits