From d69b30a84d8622a1bb93cb38cdb4d458c4d6a965 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 2 Apr 2014 10:48:13 +0100 Subject: coverity#1019376 Resource leak Change-Id: Ifa9c5a7b3aa0d219e09fa3081e66d870a508a84d --- pyuno/source/module/pyuno_impl.hxx | 3 +++ pyuno/source/module/pyuno_module.cxx | 10 ++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'pyuno/source/module') diff --git a/pyuno/source/module/pyuno_impl.hxx b/pyuno/source/module/pyuno_impl.hxx index 471ac954accd..02600cd691a5 100644 --- a/pyuno/source/module/pyuno_impl.hxx +++ b/pyuno/source/module/pyuno_impl.hxx @@ -51,6 +51,8 @@ #include #include +#include + // In Python 3, the PyString_* functions have been replaced by PyBytes_* // and PyUnicode_* functions. #if PY_MAJOR_VERSION >= 3 @@ -276,6 +278,7 @@ struct RuntimeCargo com::sun::star::uno::Reference< com::sun::star::script::XInvocationAdapterFactory2 > xAdapterFactory; com::sun::star::uno::Reference< com::sun::star::beans::XIntrospection > xIntrospection; PyRef dictUnoModule; + osl::Module testModule; bool valid; ExceptionClassMap exceptionMap; ClassSet interfaceSet; diff --git a/pyuno/source/module/pyuno_module.cxx b/pyuno/source/module/pyuno_module.cxx index 47b57aa694c0..27986e54b1ac 100644 --- a/pyuno/source/module/pyuno_module.cxx +++ b/pyuno/source/module/pyuno_module.cxx @@ -346,11 +346,13 @@ static PyObject* initPoniesMode( .replaceAll(OString('/'), OString('\\')) #endif ; - oslModule const mod( osl_loadModuleAscii(libname.getStr(), - SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL) ); - if (!mod) { abort(); } + + osl::Module &mod = runtime.getImpl()->cargo->testModule; + mod.load(OStringToOUString(libname, osl_getThreadTextEncoding()), + SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL); + if (!mod.is()) { abort(); } oslGenericFunction const pFunc( - osl_getAsciiFunctionSymbol(mod, "test_init")); + mod.getFunctionSymbol("test_init")); if (!pFunc) { abort(); } // guess casting pFunc is undefined behavior but don't see a better way ((void (SAL_CALL *)(XMultiServiceFactory*)) pFunc) (xMSF.get()); -- cgit