From 11df11dd7a24e3b9d2e3de3a343776ae42b2af53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Czerpak?= Date: Wed, 8 Oct 2014 18:00:07 +0200 Subject: [PATCH] 2014-10-08 18:00 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * src/vm/arrays.c ! added protection against internal error when ACOPY() is executed with the same array passed as source and target without any indexes which can force item move. Now ACOPY() works like in Cl*pper. --- ChangeLog.txt | 6 ++++++ src/vm/arrays.c | 12 +++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 27ee3dcdf4..450858973a 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,12 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2014-10-08 18:00 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * src/vm/arrays.c + ! added protection against internal error when ACOPY() is executed + with the same array passed as source and target without any indexes + which can force item move. Now ACOPY() works like in Cl*pper. + 2014-10-08 11:06 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * contrib/hbamf/amfdec.c ! simplified and fixed datetime decoding. diff --git a/src/vm/arrays.c b/src/vm/arrays.c index 7c243648dc..22e3c8f7f5 100644 --- a/src/vm/arrays.c +++ b/src/vm/arrays.c @@ -1452,12 +1452,14 @@ HB_BOOL hb_arrayCopy( PHB_ITEM pSrcArray, PHB_ITEM pDstArray, HB_SIZE * pnStart, if( nTarget <= nDstLen ) { #endif + if( pDstBaseArray->pItems + nTarget != pSrcBaseArray->pItems + nStart ) + { + if( nCount > nDstLen - nTarget ) + nCount = nDstLen - nTarget + 1; - if( nCount > nDstLen - nTarget ) - nCount = nDstLen - nTarget + 1; - - for( nTarget--, nStart--; nCount > 0; nCount--, nStart++, nTarget++ ) - hb_itemCopy( pDstBaseArray->pItems + nTarget, pSrcBaseArray->pItems + nStart ); + for( nTarget--, nStart--; nCount > 0; nCount--, nStart++, nTarget++ ) + hb_itemCopy( pDstBaseArray->pItems + nTarget, pSrcBaseArray->pItems + nStart ); + } } }