diff --git a/ChangeLog.txt b/ChangeLog.txt index 87596c3917..050631ce9b 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,12 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2015-10-13 21:22 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * src/rtl/mlcfunc.c + ! do not access trailing 0 byte in empty strings passed to hb_MLEval() + (thanks to Abe for information and example illustrating the problem) + * respect in return value also empty line after last EOL + 2015-10-13 15:08 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * src/rtl/memoedit.prg * always returned reformatted string after CTRL+W even if user has not diff --git a/src/rtl/mlcfunc.c b/src/rtl/mlcfunc.c index 2de2bc194b..b1a51d74e9 100644 --- a/src/rtl/mlcfunc.c +++ b/src/rtl/mlcfunc.c @@ -590,7 +590,7 @@ HB_FUNC( HB_MLEVAL ) fSoftCR = fEOL = HB_FALSE; ++nLines; - do + while( ! fSoftCR && nOffset < nLen ) { HB_SIZE nRepl; HB_WCHAR ch; @@ -667,7 +667,6 @@ HB_FUNC( HB_MLEVAL ) break; } } - while( ! fSoftCR && nOffset < nLen ); if( nRowPos == 0 && nOffset >= nPos && ! fSoftCR ) { @@ -681,19 +680,20 @@ HB_FUNC( HB_MLEVAL ) } while( nOffset < nLen && hb_vmRequestQuery() == 0 ); - if( nRowPos == 0 && nOffset >= nPos ) - { - nRowPos = nLines + 1; - nColPos = 0; - } - if( fSoftCR || fEOL ) { + ++nLines; pLineItem = hb_itemPutC( pLineItem, NULL ); pSoftItem = hb_itemPutL( pSoftItem, HB_FALSE ); hb_vmEvalBlockV( pBlock, 2, pLineItem, pSoftItem ); } + if( nRowPos == 0 && nOffset >= nPos ) + { + nRowPos = nLines; + nColPos = 0; + } + hb_itemRelease( pLineItem ); hb_itemRelease( pSoftItem ); hb_xfree( pszLine );