[Libreoffice-commits] core.git: vcl/unx

Caolán McNamara caolanm at redhat.com
Mon Dec 18 23:16:23 UTC 2017


 vcl/unx/generic/plugadapt/salplug.cxx |   20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

New commits:
commit 184ce84226b49a1b4b693f3bb8cc8569c76d864d
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Dec 18 10:49:43 2017 +0000

    coverity#1426314 silence Resource leak
    
    Change-Id: I266463184f902df11943a23fa4129086c6441783
    Reviewed-on: https://gerrit.libreoffice.org/46703
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/unx/generic/plugadapt/salplug.cxx b/vcl/unx/generic/plugadapt/salplug.cxx
index a1195dbde18a..c76077a776b4 100644
--- a/vcl/unx/generic/plugadapt/salplug.cxx
+++ b/vcl/unx/generic/plugadapt/salplug.cxx
@@ -17,7 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include <osl/module.h>
+#include <osl/module.hxx>
 #include <osl/process.h>
 
 #include <rtl/bootstrap.hxx>
@@ -75,21 +75,20 @@ static SalInstance* tryInstance( const OUString& rModuleBase, bool bForce = fals
 #endif
             "vclplug_" + rModuleBase + "lo" SAL_DLLEXTENSION );
 
-    oslModule aMod = osl_loadModuleRelative(
-        reinterpret_cast< oslGenericFunction >( &tryInstance ), aModule.pData,
-        SAL_LOADMODULE_GLOBAL );
-    if( aMod )
+    osl::Module aMod;
+    if (aMod.loadRelative(reinterpret_cast<oslGenericFunction>(&tryInstance), aModule, SAL_LOADMODULE_GLOBAL))
     {
-        salFactoryProc aProc = reinterpret_cast<salFactoryProc>(osl_getAsciiFunctionSymbol( aMod, "create_SalInstance" ));
-        if( aProc )
+        salFactoryProc aProc = reinterpret_cast<salFactoryProc>(aMod.getFunctionSymbol("create_SalInstance"));
+        if (aProc)
         {
             pInst = aProc();
             SAL_INFO(
                 "vcl.plugadapt",
                 "sal plugin " << aModule << " produced instance " << pInst);
-            if( pInst )
+            if (pInst)
             {
-                pCloseModule = aMod;
+                pCloseModule = static_cast<oslModule>(aMod);
+                aMod.release();
 
 #ifndef ANDROID
                 /*
@@ -106,8 +105,6 @@ static SalInstance* tryInstance( const OUString& rModuleBase, bool bForce = fals
                 }
 #endif
             }
-            else
-                osl_unloadModule( aMod );
         }
         else
         {
@@ -115,7 +112,6 @@ static SalInstance* tryInstance( const OUString& rModuleBase, bool bForce = fals
                 "vcl.plugadapt",
                 "could not load symbol create_SalInstance from shared object "
                     << aModule);
-            osl_unloadModule( aMod );
         }
     }
     else if (bForce)


More information about the Libreoffice-commits mailing list