From a6f735db01e5ba8c4f69b9b9a13af92b3b9541ea Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Thu, 18 Sep 2008 18:42:15 +0000 Subject: [PATCH] 2008-09-18 20:41 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/vm/thread.c * detach local parameters passed by reference to hb_threadStart() to avoid possible calling thread HVM stack corruption --- harbour/ChangeLog | 5 +++++ harbour/source/vm/thread.c | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 715838c8f2..f870001ff2 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,11 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2008-09-18 20:41 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/vm/thread.c + * detach local parameters passed by reference to hb_threadStart() + to avoid possible calling thread HVM stack corruption + 2008-09-18 19:28 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/rdd/dbfcdx/dbfcdx1.c ! fixed memory leak - Many thanks to Miguel for report diff --git a/harbour/source/vm/thread.c b/harbour/source/vm/thread.c index 816c13a5bd..83ac92535e 100644 --- a/harbour/source/vm/thread.c +++ b/harbour/source/vm/thread.c @@ -513,6 +513,7 @@ HB_FUNC( HB_THREADSTART ) { PHB_ITEM pReturn; PHB_THREADSTATE pThread; + ULONG ulPCount, ulParam; pReturn = hb_itemNew( NULL ); pThread = ( PHB_THREADSTATE ) @@ -526,6 +527,15 @@ HB_FUNC( HB_THREADSTART ) pThread->pSet = hb_setClone( hb_stackSetStruct() ); pThread->pParams = hb_arrayBaseParams(); + /* detach LOCAL variables passed by reference */ + ulPCount = hb_arrayLen( pThread->pParams ); + for( ulParam = 2; ulParam <= ulPCount; ++ulParam ) + { + PHB_ITEM pParam = hb_arrayGetItemPtr( pThread->pParams, ulParam ); + if( HB_IS_BYREF( pParam ) ) + hb_memvarDetachLocal( pParam ); + } + /* make copy of thread pointer item before we pass it to new thread * to avoid race condition */