[futurebasic] Re: [FB] Dangling handle bug in editor

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : November 2010 : Group Archive : Group : All Groups

From: Robert Purves <listrp@...>
Date: Thu, 18 Nov 2010 17:31:47 +1300
Steve wrote:


> What was the fix to the offending code below?  
> removing the DisposeH ?


>> local fn clearErrorArray
>> '~'1
>> dim   index as long
>> dim  h as Handle
>> 
>> for index = 1 to _maxErrs
>> h = gErrWindArry.errsMsgH(index)
>> long if ( h )
>> fn DisposeH( h )
>> end if
>> next
>> BlockZero( @gErrWindArry.errorType(0), _maxErrs * sizeof( ErrRec) ) // zero array
>> end fn

The fixed code, unlike the old, sets each gErrWindArry.errsMsgH() to zero. There was also a (possibly harmless) off-by-one error in the first argument to BlockZero().

local fn ClearErrorArray
'~'1
dim as long  j 

for j = 1 to _maxErrs
fn DisposeH( @gErrWindArry.errsMsgH(j) )
next
BlockZero( @gErrWindArry.errorType(1), _maxErrs * sizeof( ErrRec) )
end fn

Robert P.