Kaydet (Commit) 62be2089 authored tarafından Norbert Thiebaud's avatar Norbert Thiebaud Kaydeden (comit) Bosdonnat Cedric

coverity#1000721 Resource Leak

Change-Id: I59161a08eee0406ac71b1212a0a8697edf27911f
Reviewed-on: https://gerrit.libreoffice.org/3897Reviewed-by: 's avatarBosdonnat Cedric <cedric.bosdonnat@free.fr>
Tested-by: 's avatarBosdonnat Cedric <cedric.bosdonnat@free.fr>
üst e3258713
...@@ -31,7 +31,12 @@ SAL_DLLPUBLIC_EXPORT LibLibreOffice *lo_init( const char *install_path ) ...@@ -31,7 +31,12 @@ SAL_DLLPUBLIC_EXPORT LibLibreOffice *lo_init( const char *install_path )
{ {
if( !install_path ) if( !install_path )
return NULL; 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 ); strcpy( imp_lib, install_path );
strcat( imp_lib, "/" ); strcat( imp_lib, "/" );
strcat( imp_lib, TARGET_LIB ); strcat( imp_lib, TARGET_LIB );
...@@ -39,12 +44,14 @@ SAL_DLLPUBLIC_EXPORT LibLibreOffice *lo_init( const char *install_path ) ...@@ -39,12 +44,14 @@ SAL_DLLPUBLIC_EXPORT LibLibreOffice *lo_init( const char *install_path )
if( !dlhandle ) if( !dlhandle )
{ {
fprintf( stderr, "failed to open library '%s'\n", imp_lib ); fprintf( stderr, "failed to open library '%s'\n", imp_lib );
free( imp_lib );
return NULL; return NULL;
} }
HookFunction *pSym = (HookFunction *) dlsym( dlhandle, "liblibreoffice_hook" ); HookFunction *pSym = (HookFunction *) dlsym( dlhandle, "liblibreoffice_hook" );
if( !pSym ) { if( !pSym ) {
fprintf( stderr, "failed to find hook in library '%s'\n", imp_lib ); fprintf( stderr, "failed to find hook in library '%s'\n", imp_lib );
free( imp_lib );
return NULL; return NULL;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment