From d48bd5250b96257cd9488cb398f48e69949e3013 Mon Sep 17 00:00:00 2001 From: "Matthias Huetsch [mhu]" Date: Thu, 25 Nov 2010 14:25:45 +0100 Subject: #i115784# rsc: fix memory errors uncovered by valgrind and other tools. --- rsc/source/tools/rscchar.cxx | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'rsc') diff --git a/rsc/source/tools/rscchar.cxx b/rsc/source/tools/rscchar.cxx index c23022e4222e..2e43844b9f08 100644 --- a/rsc/source/tools/rscchar.cxx +++ b/rsc/source/tools/rscchar.cxx @@ -55,13 +55,13 @@ *************************************************************************/ char * RscChar::MakeUTF8( char * pStr, UINT16 nTextEncoding ) { - sal_Size nMaxUniCodeBuf = strlen( pStr ) + 1; - char * pOrgStr = new char[ nMaxUniCodeBuf ]; - sal_uInt32 nOrgLen = 0; - + sal_Size nMaxUniCodeBuf = strlen( pStr ) + 1; if( nMaxUniCodeBuf * 6 > 0x0FFFFF ) RscExit( 10 ); + char * pOrgStr = new char[ nMaxUniCodeBuf ]; + sal_uInt32 nOrgLen = 0; + char cOld = '1'; while( cOld != 0 ) { @@ -119,9 +119,8 @@ char * RscChar::MakeUTF8( char * pStr, UINT16 nTextEncoding ) } if( nChar > 255 ) { - rtl_freeMemory( pOrgStr ); - // Wert zu gross, oder kein 3 Ziffern + delete [] pOrgStr; return( NULL ); } c = (char)nChar; @@ -174,6 +173,7 @@ char * RscChar::MakeUTF8( char * pStr, UINT16 nTextEncoding ) &nSrcCvtBytes ); rtl_destroyTextToUnicodeConverter( hConv ); + delete[] pOrgStr, pOrgStr = 0; hConv = rtl_createUnicodeToTextConverter( RTL_TEXTENCODING_UTF8 ); // factor fo 6 is the maximum size of an UNICODE character as utf8 @@ -188,9 +188,7 @@ char * RscChar::MakeUTF8( char * pStr, UINT16 nTextEncoding ) &nSrcCvtBytes ); rtl_destroyTextToUnicodeConverter( hConv ); - - delete[] pUniCode; - delete[] pOrgStr; + delete[] pUniCode, pUniCode = 0; return pUtf8; }; -- cgit From 767f07ae9389f73209bf6920991aef977968f97b Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Sun, 13 Feb 2011 20:27:14 +0100 Subject: debuglevels: silence WaE with uncmaxci.pro+debug --- rsc/source/rscpp/cpp4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'rsc') diff --git a/rsc/source/rscpp/cpp4.c b/rsc/source/rscpp/cpp4.c index b8f90ab4f7ed..04d715f35351 100644 --- a/rsc/source/rscpp/cpp4.c +++ b/rsc/source/rscpp/cpp4.c @@ -629,7 +629,7 @@ void dumpparm(char* why) nargs, parmp - parm, why); for (i = 0; i < nargs; i++) { fprintf( pCppOut, "parm[%d] (%d) = \"%s\"\n", - i + 1, strlen(parlist[i]), parlist[i]); + i + 1, (int)strlen(parlist[i]), parlist[i]); } } #endif -- cgit