[PATCH] coverity#1000721 Resource Leak

Norbert Thiebaud (via Code Review) gerrit at gerrit.libreoffice.org
Mon May 13 16:11:34 PDT 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3897

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/97/3897/1

coverity#1000721 Resource Leak

Change-Id: I59161a08eee0406ac71b1212a0a8697edf27911f
---
M desktop/source/lib/shim.cxx
1 file changed, 8 insertions(+), 1 deletion(-)



diff --git a/desktop/source/lib/shim.cxx b/desktop/source/lib/shim.cxx
index 546d0da..8c47dc4 100644
--- a/desktop/source/lib/shim.cxx
+++ b/desktop/source/lib/shim.cxx
@@ -31,7 +31,12 @@
 {
     if( !install_path )
         return NULL;
-    char *imp_lib = (char *) malloc( strlen (install_path) + sizeof( TARGET_LIB ) + 2 );
+    char* imp_lib = (char *) malloc( strlen (install_path) + sizeof( TARGET_LIB ) + 2 );
+    if(!imp_lib)
+    {
+        fprintf( stderr, "failed to open library : not enough memory\n");
+        return NULL;
+    }
     strcpy( imp_lib, install_path );
     strcat( imp_lib, "/" );
     strcat( imp_lib, TARGET_LIB );
@@ -39,12 +44,14 @@
     if( !dlhandle )
     {
         fprintf( stderr, "failed to open library '%s'\n", imp_lib );
+        free( imp_lib );
         return NULL;
     }
 
     HookFunction *pSym = (HookFunction *) dlsym( dlhandle, "liblibreoffice_hook" );
     if( !pSym ) {
         fprintf( stderr, "failed to find hook in library '%s'\n", imp_lib );
+        free( imp_lib );
         return NULL;
     }
 

-- 
To view, visit https://gerrit.libreoffice.org/3897
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I59161a08eee0406ac71b1212a0a8697edf27911f
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Norbert Thiebaud <nthiebaud at gmail.com>



More information about the LibreOffice mailing list