diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 88a520f314..3522f3782d 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,25 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2009-01-14 01:38 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/rtl/gtxwc/gtxwc.c + ! added protection against inaccessible character cell value + what could cause accessing uninitialized memory and GPF + + * harbour/include/hbrdddbf.h + ! fixed HB_DIRTYREAD() macro not updated when RDDI_* settings were + converted from global to thread local + + * harbour/source/rdd/dbf1.c + * harbour/source/rdd/dbfntx/dbfntx1.c + * harbour/source/rdd/dbfnsx/dbfnsx1.c + * harbour/source/rdd/dbfcdx/dbfcdx1.c + * harbour/source/rdd/dbffpt/dbffpt1.c + % replaced NODE_DATA() and AREA_DATA() macros defined + in each RDD by common for all DBF bases RDDs DBFNODE_DATA() and + DBFAREA_DATA() macros defined in hbrdddbf.h to reduce possible + mistakes in code updating in the future + 2009-01-13 22:44 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/bin/hb-func.sh ! restored GCC optimization flags in hb* scripts disabled unintentionally diff --git a/harbour/include/hbrdddbf.h b/harbour/include/hbrdddbf.h index 6ca0a9d86e..783d236597 100644 --- a/harbour/include/hbrdddbf.h +++ b/harbour/include/hbrdddbf.h @@ -112,9 +112,13 @@ HB_EXTERN_BEGIN #define HB_IDXREAD_CLEANMASK HB_IDXREAD_DIRTY #define HB_IDXREAD_DIRTYMASK (HB_IDXREAD_DIRTY|HB_IDXREAD_DEFAULT) -#define HB_DIRTYREAD(w) ( ( ( ( LPDBFDATA ) SELF_RDDNODE( w )-> \ - lpvCargo )->uiDirtyRead & \ - (w)->uiDirtyRead ) != 0 ) +#define DBFNODE_DATA( r ) ( ( LPDBFDATA ) hb_stackGetTSD( ( PHB_TSD ) \ + ( r )->lpvCargo ) ) +#define DBFAREA_DATA( w ) DBFNODE_DATA( SELF_RDDNODE( w ) ) + + +#define HB_DIRTYREAD( w ) ( ( DBFAREA_DATA( w )->uiDirtyRead & \ + ( w )->uiDirtyRead ) != 0 ) /* diff --git a/harbour/source/rdd/dbf1.c b/harbour/source/rdd/dbf1.c index 71ea0ab266..1cae746a23 100644 --- a/harbour/source/rdd/dbf1.c +++ b/harbour/source/rdd/dbf1.c @@ -5380,7 +5380,7 @@ static ERRCODE hb_dbfRddInfo( LPRDDNODE pRDD, USHORT uiIndex, ULONG ulConnect, P HB_TRACE(HB_TR_DEBUG, ("hb_dbfRddInfo(%p, %hu, %lu, %p)", pRDD, uiIndex, ulConnect, pItem)); - pData = ( LPDBFDATA ) hb_stackGetTSD( ( PHB_TSD ) pRDD->lpvCargo ); + pData = DBFNODE_DATA( pRDD ); switch( uiIndex ) { diff --git a/harbour/source/rdd/dbfcdx/dbfcdx1.c b/harbour/source/rdd/dbfcdx/dbfcdx1.c index 51425c01bc..a2a7b74597 100644 --- a/harbour/source/rdd/dbfcdx/dbfcdx1.c +++ b/harbour/source/rdd/dbfcdx/dbfcdx1.c @@ -82,9 +82,6 @@ #include "rddsys.ch" #include "hbregex.h" -#define CDXNODE_DATA( p ) ( ( LPDBFDATA ) hb_stackGetTSD( ( PHB_TSD ) ( p )->lpvCargo ) ) -#define CDXAREA_DATA( p ) CDXNODE_DATA( SELF_RDDNODE( p ) ) - #ifndef HB_CDP_SUPPORT_OFF /* for nation sorting support */ #include "hbapicdp.h" @@ -7078,14 +7075,14 @@ static ERRCODE hb_cdxOpen( CDXAREAP pArea, LPDBOPENINFO pOpenInfo ) } /* open (production) structural index */ - if( CDXAREA_DATA( pArea )->fStrictStruct ? pArea->fHasTags : hb_setGetAutOpen() ) + if( DBFAREA_DATA( pArea )->fStrictStruct ? pArea->fHasTags : hb_setGetAutOpen() ) { char szFileName[ _POSIX_PATH_MAX + 1 ]; pArea->fHasTags = FALSE; hb_cdxCreateFName( pArea, NULL, NULL, szFileName, NULL ); if ( hb_spFile( ( BYTE * ) szFileName, NULL ) || - CDXAREA_DATA( pArea )->fStrictStruct ) + DBFAREA_DATA( pArea )->fStrictStruct ) { DBORDERINFO pOrderInfo; @@ -7300,7 +7297,7 @@ static ERRCODE hb_cdxOrderListClear( CDXAREAP pArea ) if ( FAST_GOCOLD( ( AREAP ) pArea ) == FAILURE ) return FAILURE; - hb_cdxOrdListClear( pArea, !( CDXAREA_DATA( pArea )->fStrictStruct ? + hb_cdxOrdListClear( pArea, !( DBFAREA_DATA( pArea )->fStrictStruct ? pArea->fHasTags : hb_setGetAutOpen() ), NULL ); pArea->uiTag = 0; @@ -7323,7 +7320,7 @@ static ERRCODE hb_cdxOrderListDelete( CDXAREAP pArea, LPDBORDERINFO pOrderInfo ) hb_cdxCreateFName( pArea, hb_itemGetCPtr( pOrderInfo->atomBagName ), &fProd, szFileName, szTagName ); - if( fProd && ( CDXAREA_DATA( pArea )->fStrictStruct ? + if( fProd && ( DBFAREA_DATA( pArea )->fStrictStruct ? pArea->fHasTags : hb_setGetAutOpen() ) ) pIndex = NULL; else @@ -7606,7 +7603,7 @@ static ERRCODE hb_cdxOrderCreate( CDXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo if ( !pArea->lpdbOrdCondInfo || ( pArea->lpdbOrdCondInfo->fAll && !pArea->lpdbOrdCondInfo->fAdditive ) ) - hb_cdxOrdListClear( pArea, !( CDXAREA_DATA( pArea )->fStrictStruct ? + hb_cdxOrdListClear( pArea, !( DBFAREA_DATA( pArea )->fStrictStruct ? pArea->fHasTags : hb_setGetAutOpen() ), NULL ); pIndex = hb_cdxFindBag( pArea, szFileName ); @@ -7730,7 +7727,7 @@ static ERRCODE hb_cdxOrderCreate( CDXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo if ( pArea->lpdbOrdCondInfo && ( !pArea->lpdbOrdCondInfo->fAll && !pArea->lpdbOrdCondInfo->fAdditive ) ) { - hb_cdxOrdListClear( pArea, !( CDXAREA_DATA( pArea )->fStrictStruct ? + hb_cdxOrdListClear( pArea, !( DBFAREA_DATA( pArea )->fStrictStruct ? pArea->fHasTags : hb_setGetAutOpen() ), NULL ); } hb_cdxIndexUnLockWrite( pIndex ); @@ -7739,7 +7736,7 @@ static ERRCODE hb_cdxOrderCreate( CDXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo { pArea->fHasTags = TRUE; if ( !pArea->fReadonly && ( pArea->dbfHeader.bHasTags & 0x01 ) == 0 && - ( hb_setGetAutOpen() || CDXAREA_DATA( pArea )->fStrictStruct ) ) + ( hb_setGetAutOpen() || DBFAREA_DATA( pArea )->fStrictStruct ) ) SELF_WRITEDBHEADER( ( AREAP ) pArea ); } else @@ -7807,7 +7804,7 @@ static ERRCODE hb_cdxOrderDestroy( CDXAREAP pArea, LPDBORDERINFO pOrderInfo ) pArea->fHasTags = FALSE; if ( !pArea->fReadonly && ( pArea->dbfHeader.bHasTags & 0x01 ) != 0 && ( hb_setGetAutOpen() || - CDXAREA_DATA( pArea )->fStrictStruct ) ) + DBFAREA_DATA( pArea )->fStrictStruct ) ) SELF_WRITEDBHEADER( ( AREAP ) pArea ); } } @@ -8638,7 +8635,7 @@ static ERRCODE hb_cdxRddInfo( LPRDDNODE pRDD, USHORT uiIndex, ULONG ulConnect, P HB_TRACE(HB_TR_DEBUG, ("hb_cdxRddInfo(%p, %hu, %lu, %p)", pRDD, uiIndex, ulConnect, pItem)); - pData = CDXNODE_DATA( pRDD ); + pData = DBFNODE_DATA( pRDD ); switch( uiIndex ) { diff --git a/harbour/source/rdd/dbffpt/dbffpt1.c b/harbour/source/rdd/dbffpt/dbffpt1.c index d846b9f433..9ab1c958ec 100644 --- a/harbour/source/rdd/dbffpt/dbffpt1.c +++ b/harbour/source/rdd/dbffpt/dbffpt1.c @@ -78,9 +78,6 @@ # include "hbapicdp.h" #endif -#define FPTNODE_DATA( p ) ( ( LPDBFDATA ) hb_stackGetTSD( ( PHB_TSD ) ( p )->lpvCargo ) ) -#define FPTAREA_DATA( p ) FPTNODE_DATA( SELF_RDDNODE( p ) ) - #define FPT_BLOCK_OFFSET( b ) ( ( HB_FOFFSET ) ( b ) * \ ( HB_FOFFSET ) pArea->uiMemoBlockSize ) @@ -4685,7 +4682,7 @@ static ERRCODE hb_fptInfo( FPTAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) } else { - LPDBFDATA pData = FPTAREA_DATA( pArea ); + LPDBFDATA pData = DBFAREA_DATA( pArea ); char * szMFileExt; if( pData->szMemoExt[ 0 ] ) hb_itemPutC( pItem, pData->szMemoExt ); @@ -4987,7 +4984,7 @@ static ERRCODE hb_fptRddInfo( LPRDDNODE pRDD, USHORT uiIndex, ULONG ulConnect, P HB_TRACE(HB_TR_DEBUG, ("hb_fptRddInfo(%p, %hu, %lu, %p)", pRDD, uiIndex, ulConnect, pItem)); - pData = FPTNODE_DATA( pRDD ); + pData = DBFNODE_DATA( pRDD ); switch( uiIndex ) { diff --git a/harbour/source/rdd/dbfnsx/dbfnsx1.c b/harbour/source/rdd/dbfnsx/dbfnsx1.c index 24a4356e63..39ff9437c3 100644 --- a/harbour/source/rdd/dbfnsx/dbfnsx1.c +++ b/harbour/source/rdd/dbfnsx/dbfnsx1.c @@ -76,9 +76,6 @@ static RDDFUNCS nsxSuper; static USHORT s_uiRddId; -#define NSXNODE_DATA( p ) ( ( LPDBFDATA ) hb_stackGetTSD( ( PHB_TSD ) ( p )->lpvCargo ) ) -#define NSXAREA_DATA( p ) NSXNODE_DATA( SELF_RDDNODE( p ) ) - #define hb_nsxKeyFree(K) hb_xfree(K) #define hb_nsxFileOffset(I,B) ( (B) << ( (I)->LargeFile ? NSX_PAGELEN_BITS : 0 ) ) #define hb_nsxGetRecSize(r) ( (r) < 0x10000 ? 2 : ( (r) < 0x1000000 ? 3 : 4 ) ) @@ -1612,7 +1609,7 @@ static LPTAGINFO hb_nsxTagNew( LPNSXINDEX pIndex, const char * szTagName, pTag->fUsrDescend = !pTag->AscendKey; pTag->UniqueKey = fUnique; pTag->Custom = fCustom; - pTag->MultiKey = fCustom && NSXAREA_DATA( pIndex->pArea )->fMultiKey; + pTag->MultiKey = fCustom && DBFAREA_DATA( pIndex->pArea )->fMultiKey; pTag->KeyType = ucKeyType; pTag->KeyLength = uiKeyLen; pTag->TrailChar = bTrail; @@ -6422,14 +6419,14 @@ static ERRCODE hb_nsxOpen( NSXAREAP pArea, LPDBOPENINFO pOpenInfo ) errCode = SUPER_OPEN( ( AREAP ) pArea, pOpenInfo ); - if( errCode == SUCCESS && ( NSXAREA_DATA( pArea )->fStrictStruct ? + if( errCode == SUCCESS && ( DBFAREA_DATA( pArea )->fStrictStruct ? pArea->fHasTags : hb_setGetAutOpen() ) ) { char szFileName[ _POSIX_PATH_MAX + 1 ]; hb_nsxCreateFName( pArea, NULL, NULL, szFileName, NULL ); if( hb_spFile( ( BYTE * ) szFileName, NULL ) || - NSXAREA_DATA( pArea )->fStrictStruct ) + DBFAREA_DATA( pArea )->fStrictStruct ) { DBORDERINFO pOrderInfo; @@ -6839,7 +6836,7 @@ static ERRCODE hb_nsxOrderCreate( NSXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo *pIndexPtr = pIndex; } if( pIndex->Production && !pArea->fHasTags && - ( NSXAREA_DATA( pArea )->fStrictStruct || hb_setGetAutOpen() ) ) + ( DBFAREA_DATA( pArea )->fStrictStruct || hb_setGetAutOpen() ) ) { pArea->fHasTags = TRUE; if( !pArea->fReadonly && ( pArea->dbfHeader.bHasTags & 0x01 ) == 0 ) @@ -6886,7 +6883,7 @@ static ERRCODE hb_nsxOrderDestroy( NSXAREAP pArea, LPDBORDERINFO pOrderInfo ) pIndex->fDelete = TRUE; hb_nsxIndexFree( pIndex ); if( fProd && pArea->fHasTags && - ( NSXAREA_DATA( pArea )->fStrictStruct || hb_setGetAutOpen() ) ) + ( DBFAREA_DATA( pArea )->fStrictStruct || hb_setGetAutOpen() ) ) { pArea->fHasTags = FALSE; if( !pArea->fReadonly && ( pArea->dbfHeader.bHasTags & 0x01 ) != 0 ) @@ -7705,7 +7702,7 @@ static ERRCODE hb_nsxOrderListClear( NSXAREAP pArea ) while( *pIndexPtr ) { pIndex = *pIndexPtr; - if( pIndex->Production && ( NSXAREA_DATA( pArea )->fStrictStruct ? + if( pIndex->Production && ( DBFAREA_DATA( pArea )->fStrictStruct ? pArea->fHasTags : hb_setGetAutOpen() ) ) { pIndexPtr = &pIndex->pNext; @@ -7737,7 +7734,7 @@ static ERRCODE hb_nsxOrderListDelete( NSXAREAP pArea, LPDBORDERINFO pOrderInfo ) pIndex = hb_nsxFindBag( pArea, szFileName ); if( pIndex && !( pIndex->Production && - ( NSXAREA_DATA( pArea )->fStrictStruct ? + ( DBFAREA_DATA( pArea )->fStrictStruct ? pArea->fHasTags : hb_setGetAutOpen() ) ) ) { pIndexPtr = &pArea->lpIndexes; @@ -7837,7 +7834,7 @@ static ERRCODE hb_nsxRddInfo( LPRDDNODE pRDD, USHORT uiIndex, ULONG ulConnect, P HB_TRACE(HB_TR_DEBUG, ("hb_nsxRddInfo(%p, %hu, %lu, %p)", pRDD, uiIndex, ulConnect, pItem)); - pData = NSXNODE_DATA( pRDD ); + pData = DBFNODE_DATA( pRDD ); switch( uiIndex ) { diff --git a/harbour/source/rdd/dbfntx/dbfntx1.c b/harbour/source/rdd/dbfntx/dbfntx1.c index 0b21f83e44..3b1c5c5ffa 100644 --- a/harbour/source/rdd/dbfntx/dbfntx1.c +++ b/harbour/source/rdd/dbfntx/dbfntx1.c @@ -157,9 +157,6 @@ static RDDFUNCS ntxSuper; static USHORT s_uiRddId; -#define NTXNODE_DATA( p ) ( ( LPDBFDATA ) hb_stackGetTSD( ( PHB_TSD ) ( p )->lpvCargo ) ) -#define NTXAREA_DATA( p ) NTXNODE_DATA( SELF_RDDNODE( p ) ) - #define hb_ntxKeyFree(K) hb_xfree(K) #define hb_ntxFileOffset(I,B) ( (B) << ( (I)->LargeFile ? NTXBLOCKBITS : 0 ) ) #define hb_ntxPageBuffer(p) ( (p)->buffer ) @@ -1416,7 +1413,7 @@ static LPTAGINFO hb_ntxTagNew( LPNTXINDEX pIndex, pTag->fUsrDescend = !pTag->AscendKey; pTag->UniqueKey = fUnique; pTag->Custom = fCustom; - pTag->MultiKey = fCustom && NTXAREA_DATA( pIndex->Owner )->fMultiKey; + pTag->MultiKey = fCustom && DBFAREA_DATA( pIndex->Owner )->fMultiKey; pTag->KeyType = bKeyType; pTag->KeyLength = uiKeyLen; pTag->KeyDec = uiKeyDec; @@ -6034,14 +6031,14 @@ static ERRCODE ntxOpen( NTXAREAP pArea, LPDBOPENINFO pOpenInfo ) errCode = SUPER_OPEN( ( AREAP ) pArea, pOpenInfo ); - if( errCode == SUCCESS && NTXAREA_DATA( pArea )->fStruct && - ( NTXAREA_DATA( pArea )->fStrictStruct ? pArea->fHasTags : hb_setGetAutOpen() ) ) + if( errCode == SUCCESS && DBFAREA_DATA( pArea )->fStruct && + ( DBFAREA_DATA( pArea )->fStrictStruct ? pArea->fHasTags : hb_setGetAutOpen() ) ) { char szFileName[ _POSIX_PATH_MAX + 1 ]; hb_ntxCreateFName( pArea, NULL, NULL, szFileName, NULL ); if( hb_spFile( ( BYTE * ) szFileName, NULL ) || - NTXAREA_DATA( pArea )->fStrictStruct ) + DBFAREA_DATA( pArea )->fStrictStruct ) { DBORDERINFO pOrderInfo; @@ -6237,7 +6234,7 @@ static ERRCODE ntxOrderCreate( NTXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo ) SELF_GOTO( ( AREAP ) pArea, ulRecNo ); - pData = NTXAREA_DATA( pArea ); + pData = DBFAREA_DATA( pArea ); /* * abBagName -> cBag, atomBagName -> cTag * The following scheme implemented: @@ -6547,8 +6544,8 @@ static ERRCODE ntxOrderDestroy( NTXAREAP pArea, LPDBORDERINFO pOrderInfo ) pIndex->fDelete = TRUE; hb_ntxIndexFree( pIndex ); if( fProd && pArea->fHasTags && - NTXAREA_DATA( pArea )->fStruct && - ( NTXAREA_DATA( pArea )->fStrictStruct || hb_setGetAutOpen() ) ) + DBFAREA_DATA( pArea )->fStruct && + ( DBFAREA_DATA( pArea )->fStrictStruct || hb_setGetAutOpen() ) ) { pArea->fHasTags = FALSE; if( !pArea->fReadonly && ( pArea->dbfHeader.bHasTags & 0x01 ) != 0 ) @@ -7376,8 +7373,8 @@ static ERRCODE ntxOrderListClear( NTXAREAP pArea ) while( *pIndexPtr ) { pIndex = *pIndexPtr; - if( NTXAREA_DATA( pArea )->fStruct && pIndex->Production && - ( NTXAREA_DATA( pArea )->fStrictStruct ? pArea->fHasTags : + if( DBFAREA_DATA( pArea )->fStruct && pIndex->Production && + ( DBFAREA_DATA( pArea )->fStrictStruct ? pArea->fHasTags : hb_setGetAutOpen() ) ) { pIndexPtr = &pIndex->pNext; @@ -7408,8 +7405,8 @@ static ERRCODE ntxOrderListDelete( NTXAREAP pArea, LPDBORDERINFO pOrderInfo ) szFileName, szTagName ); pIndex = hb_ntxFindBag( pArea, szFileName ); - if( pIndex && !( pIndex->Production && NTXAREA_DATA( pArea )->fStruct && - ( NTXAREA_DATA( pArea )->fStrictStruct ? + if( pIndex && !( pIndex->Production && DBFAREA_DATA( pArea )->fStruct && + ( DBFAREA_DATA( pArea )->fStrictStruct ? pArea->fHasTags : hb_setGetAutOpen() ) ) ) { pIndexPtr = &pArea->lpIndexes; @@ -7510,7 +7507,7 @@ static ERRCODE ntxInit( LPRDDNODE pRDD ) errCode = SUPER_INIT( pRDD ); #if !defined( HB_NTX_NOMULTITAG ) if( errCode == SUCCESS ) - NTXNODE_DATA( pRDD )->fMultiTag = TRUE; + DBFNODE_DATA( pRDD )->fMultiTag = TRUE; #endif return errCode; @@ -7522,7 +7519,7 @@ static ERRCODE ntxRddInfo( LPRDDNODE pRDD, USHORT uiIndex, ULONG ulConnect, PHB_ HB_TRACE(HB_TR_DEBUG, ("ntxRddInfo(%p, %hu, %lu, %p)", pRDD, uiIndex, ulConnect, pItem)); - pData = NTXNODE_DATA( pRDD ); + pData = DBFNODE_DATA( pRDD ); switch( uiIndex ) { diff --git a/harbour/source/rtl/gtxwc/gtxwc.c b/harbour/source/rtl/gtxwc/gtxwc.c index 63b1dba718..ae98594c37 100644 --- a/harbour/source/rtl/gtxwc/gtxwc.c +++ b/harbour/source/rtl/gtxwc/gtxwc.c @@ -2510,7 +2510,14 @@ static void hb_gt_xwc_RepaintChar( PXWND_DEF wnd, int colStart, int rowStart, in */ while( icol <= colStop ) { - HB_GTSELF_GETSCRCHAR( wnd->pGT, irow, icol, &color, &attr, &usCh16 ); + if( HB_GTSELF_GETSCRCHAR( wnd->pGT, irow, icol, &color, &attr, &usCh16 ) ) + { + color = 0x07; + attr = 0; + usCh16 = ' '; + } + else + usCh16 &= 0xff; ulCurr = hb_gt_xwc_HashCurrChar( attr, color, usCh16 ); if( wnd->charTrans[ usCh16 ].inverse ) {