[Libreoffice-commits] .: 2 commits - desktop/scripts desktop/unx
Caolán McNamara
caolan at kemper.freedesktop.org
Wed Mar 23 05:58:46 PDT 2011
desktop/scripts/soffice.sh | 2 -
desktop/unx/source/splashx.c | 12 +++++---
desktop/unx/source/start.c | 60 ++++++++++++++++++++++++++++++-------------
3 files changed, 51 insertions(+), 23 deletions(-)
New commits:
commit cc3ff1b5e63a27057a52597e2e3ea0926ac479a8
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Mar 23 12:58:37 2011 +0000
add --trace-children=yes
diff --git a/desktop/scripts/soffice.sh b/desktop/scripts/soffice.sh
index 76af9bc..21023a9 100755
--- a/desktop/scripts/soffice.sh
+++ b/desktop/scripts/soffice.sh
@@ -73,7 +73,7 @@ if [ -e $sd_prog/ooenv ] ; then
fi
if [ "$VALGRIND" != "" ]; then
- VALGRINDCHECK="valgrind --tool=$VALGRIND --error-exitcode=101"
+ VALGRINDCHECK="valgrind --tool=$VALGRIND --trace-children=yes --error-exitcode=101"
export VALGRINDCHECK
G_SLICE=always-malloc
export G_SLICE
commit d3cece5f21b09e3e91a95244ad5120bf8ae3c3d2
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Mar 23 12:45:55 2011 +0000
fix various leaks
diff --git a/desktop/unx/source/splashx.c b/desktop/unx/source/splashx.c
index 9e0d237..d7d8b1d 100755
--- a/desktop/unx/source/splashx.c
+++ b/desktop/unx/source/splashx.c
@@ -115,11 +115,12 @@ static unsigned char **bitmap_rows = NULL;
# define PNG_TRANSFORM_GRAY_TO_RGB 0x2000
#endif
+png_structp png_ptr = NULL;
+png_infop info_ptr = NULL;
+
int splash_load_bmp( const char *filename )
{
FILE *file;
- png_structp png_ptr;
- png_infop info_ptr;
if ( !(file = fopen( filename, "r" ) ) )
return 0;
@@ -618,8 +619,11 @@ void splash_draw_progress( int progress )
void splash_close_window()
{
XCloseDisplay( display );
-
- // leak it is faster
+#ifdef USE_LIBPNG
+ png_destroy_read_struct( &png_ptr, &info_ptr, NULL );
+#else
+ free( bitmap_rows );
+#endif
bitmap_rows = NULL;
}
diff --git a/desktop/unx/source/start.c b/desktop/unx/source/start.c
index 2b9b3e3..1b40978 100755
--- a/desktop/unx/source/start.c
+++ b/desktop/unx/source/start.c
@@ -139,8 +139,8 @@ child_spawn ( Args *args, sal_Bool bAllArgs, sal_Bool bWithStatus )
rtl_uString_newConcat( &pApp, pApp, args->pAppPath );
rtl_uString_newFromAscii( &pTmp, "/soffice.bin" );
rtl_uString_newConcat( &pApp, pApp, pTmp );
-
- rtl_uString_new( &pTmp );
+ rtl_uString_release( pTmp );
+ pTmp = NULL;
/* copy args */
nArgs = bAllArgs ? args->nArgsTotal : args->nArgsEnv;
@@ -152,8 +152,8 @@ child_spawn ( Args *args, sal_Bool bAllArgs, sal_Bool bWithStatus )
{
/* add the pipe arg */
snprintf (buffer, 63, "--splash-pipe=%d", status_pipe[1]);
- ppArgs[nArgs] = NULL;
- rtl_uString_newFromAscii( &ppArgs[nArgs], buffer );
+ rtl_uString_newFromAscii( &pTmp, buffer );
+ ppArgs[nArgs] = pTmp;
++nArgs;
}
@@ -165,13 +165,19 @@ child_spawn ( Args *args, sal_Bool bAllArgs, sal_Bool bWithStatus )
NULL, 0,
&info->child );
+ if (pTmp)
+ rtl_uString_release( pTmp );
+ free (ppArgs);
+
if ( nError != osl_Process_E_None )
{
fprintf( stderr, "ERROR %d forking process", nError );
ustr_debug( "", pApp );
+ rtl_uString_release( pApp );
_exit (1);
}
+ rtl_uString_release( pApp );
close( status_pipe[1] );
return info;
@@ -327,6 +333,7 @@ get_pipe_path( rtl_uString *pAppPath )
ustr_debug( "result", pResult );
/* cleanup */
+ rtl_uString_release( pMd5hash );
rtl_uString_release( pPath );
rtl_uString_release( pTmp );
rtl_uString_release( pBasePath );
@@ -538,10 +545,14 @@ load_splash_image( rtl_uString *pUAppPath )
strcat (pLocale, "_");
strcat (pLocale, pCountry->buffer);
+ rtl_string_release( pCountry );
+ rtl_string_release( pLang );
+
pAppPath = ustr_to_str (pUAppPath);
pBuffer = malloc (pAppPath->length + nLocSize + 256);
strcpy (pBuffer, pAppPath->buffer);
pSuffix = pBuffer + pAppPath->length;
+ rtl_string_release( pAppPath );
strcpy (pSuffix, "/edition/intro");
strcat (pSuffix, pLocale);
@@ -734,6 +745,8 @@ exec_pagein (Args *args)
argv[3] = (char *)args->pPageinType;
argv[4] = NULL;
+ rtl_string_release( app_path );
+
pagein_execute (args->pPageinType ? 4 : 3, argv);
free (argv[1]);
@@ -741,28 +754,33 @@ exec_pagein (Args *args)
static void extend_library_path (const char *new_element)
{
+ rtl_uString *pEnvName=NULL, *pOrigEnvVar=NULL, *pNewEnvVar=NULL;
const char *pathname;
#ifdef AIX
pathname = "LIBPATH";
#else
pathname = "LD_LIBRARY_PATH";
#endif
- char *buffer;
- char *oldpath;
-
- oldpath = getenv (pathname);
- buffer = malloc (strlen (new_element) + strlen (pathname) +
- (oldpath ? strlen (oldpath) : 0)+ 4);
- strcpy (buffer, pathname);
- strcpy (buffer, "=");
- strcpy (buffer, new_element);
- if (oldpath) {
- strcat (buffer, ":");
- strcat (buffer, oldpath);
+
+ rtl_uString_newFromAscii( &pEnvName, pathname );
+
+ osl_getEnvironment( pEnvName, &pOrigEnvVar );
+
+ rtl_uString_newFromAscii( &pNewEnvVar, new_element );
+ if (pOrigEnvVar->length)
+ {
+ rtl_uString *pDelim = NULL;
+ rtl_uString_newFromAscii( &pDelim, ":" );
+ rtl_uString_newConcat( &pNewEnvVar, pNewEnvVar, pDelim );
+ rtl_uString_newConcat( &pNewEnvVar, pNewEnvVar, pOrigEnvVar );
+ rtl_uString_release( pDelim );
}
- /* deliberately leak buffer - many OS' don't dup at this point */
- putenv (buffer);
+ osl_setEnvironment( pEnvName, pNewEnvVar );
+
+ rtl_uString_release( pNewEnvVar );
+ rtl_uString_release( pOrigEnvVar );
+ rtl_uString_release( pEnvName );
}
static void
@@ -802,6 +820,7 @@ exec_javaldx (Args *args)
pTmp = NULL;
rtl_uString_newFromAscii( &pTmp, "/../ure/bin/javaldx" );
rtl_uString_newConcat( &pApp, pApp, pTmp );
+ rtl_uString_release( pTmp );
/* unset to avoid bogus console output */
rtl_uString_newFromAscii( &pEnvironment[0], "G_SLICE" );
@@ -816,6 +835,11 @@ exec_javaldx (Args *args)
&fileOut,
NULL);
+ rtl_uString_release( pEnvironment[0] );
+ rtl_uString_release( ppArgs[nArgs-1] );
+ rtl_uString_release( pApp );
+ free( ppArgs );
+
if( err != osl_Process_E_None)
{
fprintf (stderr, "Warning: failed to launch javaldx - java may not fuction correctly\n");
More information about the Libreoffice-commits
mailing list