diff options
author | Norbert Thiebaud <nthiebaud@gmail.com> | 2013-05-13 18:11:22 -0500 |
---|---|---|
committer | Bosdonnat Cedric <cedric.bosdonnat@free.fr> | 2013-05-14 13:42:33 +0000 |
commit | 62be20899d952d54e5ee5874d26ffb20b8f70eef (patch) | |
tree | 633e2390de5fffcb24fef0565ad81cd47cc964d2 /desktop | |
parent | e3258713793f03d6cf96c19ff4c5d15a0cd666f1 (diff) |
coverity#1000721 Resource Leak
Change-Id: I59161a08eee0406ac71b1212a0a8697edf27911f
Reviewed-on: https://gerrit.libreoffice.org/3897
Reviewed-by: Bosdonnat Cedric <cedric.bosdonnat@free.fr>
Tested-by: Bosdonnat Cedric <cedric.bosdonnat@free.fr>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/lib/shim.cxx | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/desktop/source/lib/shim.cxx b/desktop/source/lib/shim.cxx index 546d0da99ff0..8c47dc42ad1e 100644 --- a/desktop/source/lib/shim.cxx +++ b/desktop/source/lib/shim.cxx @@ -31,7 +31,12 @@ SAL_DLLPUBLIC_EXPORT LibLibreOffice *lo_init( const char *install_path ) { 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 @@ SAL_DLLPUBLIC_EXPORT LibLibreOffice *lo_init( const char *install_path ) 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; } |