From 71eb525cdfb99897d1d66ee315f822b5932711cb Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 3 Jun 2008 08:41:32 +0000 Subject: [PATCH] 2008-06-03 10:12 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * source/vm/extend.c ! Reverted previous change. Caller should check the retval of hb_storclen_buffer() and free the pointer in case it's zero. Thanks Przemek. * contrib/hbw32/w32_regc.c * contrib/hbhpdf/harupdf.c * contrib/hbwhat32/_winsys.c * utils/hbmake/readline.c ! Fixed hb_storclen_buffer() calls. * contrib/hbwhat32/_winsys.c ! SYSTEMPARAMETERSINFO() fixed retval and leaks. ; Please test. * source/rtl/tget.prg ! Typo. --- harbour/ChangeLog | 24 +++++++++++++++-- harbour/contrib/hbcurl/hbcurl.c | 3 ++- harbour/contrib/hbhpdf/harupdf.c | 3 ++- harbour/contrib/hbw32/w32_regc.c | 4 ++- harbour/contrib/hbwhat32/_winsys.c | 41 ++++++++++++++---------------- harbour/source/rtl/tget.prg | 4 +-- harbour/source/vm/extend.c | 4 --- harbour/utils/hbmake/readline.c | 4 ++- 8 files changed, 53 insertions(+), 34 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index dac7352769..e12d46d1f0 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,26 @@ 2008-12-31 13:59 UTC+0100 Foo Bar */ +2008-06-03 10:12 UTC+0100 Viktor Szakats (harbour.01 syenar hu) + * source/vm/extend.c + ! Reverted previous change. Caller should check the + retval of hb_storclen_buffer() and free the pointer + in case it's zero. + Thanks Przemek. + + * contrib/hbw32/w32_regc.c + * contrib/hbhpdf/harupdf.c + * contrib/hbwhat32/_winsys.c + * utils/hbmake/readline.c + ! Fixed hb_storclen_buffer() calls. + + * contrib/hbwhat32/_winsys.c + ! SYSTEMPARAMETERSINFO() fixed retval and leaks. + ; Please test. + + * source/rtl/tget.prg + ! Typo. + 2008-06-03 09:11 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * include/rdd.api + Added necessary conversions. @@ -22,8 +42,8 @@ ! Fixed indentation. * contrib/hbhpdf/harupdf.c - ! Fixed hpdf_ReadFromStream() fixed to not overflow - to buffer in hb_storlen_buffer(). + ! Fixed hpdf_ReadFromStream() to not overflow + to buffer in hb_storclen_buffer(). 2008-06-03 01:31 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * source/vm/extend.c diff --git a/harbour/contrib/hbcurl/hbcurl.c b/harbour/contrib/hbcurl/hbcurl.c index e12445a4af..f576efeae1 100644 --- a/harbour/contrib/hbcurl/hbcurl.c +++ b/harbour/contrib/hbcurl/hbcurl.c @@ -489,7 +489,8 @@ HB_FUNC( CURL_EASY_RECV ) hb_retnl( ( long ) curl_easy_recv( hb_curl->curl, buffer, size, &size ) ); - hb_storclen_buffer( ( char * ) buffer, size, 2 ); + if( ! hb_storclen_buffer( ( char * ) buffer, size, 2 ) ) + hb_free( buffer ); } } diff --git a/harbour/contrib/hbhpdf/harupdf.c b/harbour/contrib/hbhpdf/harupdf.c index 9ee4659873..b706b11534 100644 --- a/harbour/contrib/hbhpdf/harupdf.c +++ b/harbour/contrib/hbhpdf/harupdf.c @@ -187,7 +187,8 @@ HB_FUNC( HPDF_READFROMSTREAM ) hb_retnl( (long) HPDF_ReadFromStream( HPDF_Doc_par( 1 ), buffer, &size ) ); - hb_storclen_buffer( ( char * ) buffer, size, 2 ); + if( ! hb_storclen_buffer( ( char * ) buffer, size, 2 ) ) + hb_xfree( buffer ); } //----------------------------------------------------------------------// // HPdf_ResetStream( hDoc ) -> hStatus diff --git a/harbour/contrib/hbw32/w32_regc.c b/harbour/contrib/hbw32/w32_regc.c index 280d8d79f1..c0c1cb7be8 100644 --- a/harbour/contrib/hbw32/w32_regc.c +++ b/harbour/contrib/hbw32/w32_regc.c @@ -152,7 +152,9 @@ HB_FUNC( WIN32_REGQUERYVALUEEX ) &nSize ); hb_stornl( nType, 4 ); - hb_storclen_buffer( ( char * ) cValue, nSize, 5 ); + + if( ! hb_storclen_buffer( ( char * ) cValue, nSize, 5 ) ) + hb_free( cValue ); } } diff --git a/harbour/contrib/hbwhat32/_winsys.c b/harbour/contrib/hbwhat32/_winsys.c index 7b2786f2a0..7ce217e651 100644 --- a/harbour/contrib/hbwhat32/_winsys.c +++ b/harbour/contrib/hbwhat32/_winsys.c @@ -184,35 +184,32 @@ HB_FUNC( MULDIV ) // HB_FUNC( SYSTEMPARAMETERSINFO ) { - char *cText; PHB_ITEM pBuffer = hb_param( 3, HB_IT_STRING ); if( pBuffer ) { - cText = (char*) hb_xgrab( hb_itemGetCLen( pBuffer )+1 ); + char * cText = (char*) hb_xgrab( hb_itemGetCLen( pBuffer )+1 ); hb_xmemcpy( cText, hb_itemGetC( pBuffer ), hb_itemGetCLen( pBuffer )+1 ); - } - else - { - hb_retl( FALSE ); - return; + + if( SystemParametersInfo( (UINT) hb_parni( 1 ), + (UINT) hb_parni( 2 ), + cText, + (UINT) hb_parni( 4 ) ) ) + { + if( ISBYREF( 3 ) ) + { + if( ! hb_storclen_buffer( cText, hb_itemGetCLen( pBuffer ), 3 ) ) + hb_xfree( xText ); + + hb_retl( TRUE ); + return; + } + } + + hb_xfree( xText ); } - if( SystemParametersInfo( (UINT) hb_parni( 1 ), - (UINT) hb_parni( 2 ), - cText, - (UINT) hb_parni( 4 ) ) ) - { - if( ISBYREF( 3 ) ) - { - hb_storclen_buffer( cText, hb_itemGetCLen( pBuffer ), 3 ); - hb_retl( TRUE ); - } - } - else - { - hb_retl( FALSE ); - } + hb_retl( FALSE ); } //-------------------------------------------------------------------// diff --git a/harbour/source/rtl/tget.prg b/harbour/source/rtl/tget.prg index 7787182701..def4e0c5d1 100644 --- a/harbour/source/rtl/tget.prg +++ b/harbour/source/rtl/tget.prg @@ -842,8 +842,8 @@ METHOD delRight() CLASS Get RETURN Self -/* NOTE ::wordLeft() - ::delWordRight() */ +/* ::wordLeft() + ::delWordRight() */ METHOD delWordLeft() CLASS Get diff --git a/harbour/source/vm/extend.c b/harbour/source/vm/extend.c index 5514bcd05e..b4d4c641e0 100644 --- a/harbour/source/vm/extend.c +++ b/harbour/source/vm/extend.c @@ -1007,10 +1007,6 @@ HB_EXPORT int hb_storclen_buffer( char * szText, ULONG ulLen, int iParam, ... ) } } - /* Make sure to free the pointer in case it couldn't be stored. */ - if( szText ) - hb_xfree( szText ); - return 0; } diff --git a/harbour/utils/hbmake/readline.c b/harbour/utils/hbmake/readline.c index 863fc99927..f39c543bea 100644 --- a/harbour/utils/hbmake/readline.c +++ b/harbour/utils/hbmake/readline.c @@ -242,7 +242,9 @@ HB_FUNC( HB_FREADLINE ) pBuffer = hb_fsReadLine( hFileHandle, &lSize, Term, iTermSizes, iTerms, &bFound, &bEOF ); - hb_storclen_buffer( (char*) pBuffer, lSize, 2 ); + if( ! hb_storclen_buffer( (char*) pBuffer, lSize, 2 ) ) + hb_xfree( pBuffer ); + hb_retnl( bEOF ? -1 : 0 ); hb_xfree( Term ); hb_xfree( iTermSizes );