remobjects/pascalscript

DoubleFree error somewhere near TPSBinValueOp.Destroy;

Opened this issue · 2 comments

Eror raised in compilation time.

Script for reproduce:

program dev;

type
TItemDef = record
  ItemIs: Boolean;
end;

function testfunc: TItemDef;
begin
  Result.ItemIs := True;
end;

begin
  if testfunc.ItemIs = False then //error raised when compiler processing this line.
     Exit; 
end.  
pult commented

The sequence of code calls:

function TPSExec.RunScript
... repeat ... while ...
case Cmd of
CM_CO
  DoBooleanCalc(Vs.P, Vd.P, v3.P, vs.aType, vd.aType, v3.aType, CalcType);
CM_PO
  FStack.Pop;
CM_PO
  FStack.Pop;
CM_SF  
  ReadVariable(vd, True) 
    case VarType
      0:
        if Param >= Cardinal(FStack.Count) then // Param == 2; Stack.Count == 1
          CMD_Err(erOutOfStackRange) *** ERROR ...

Resume: Or bad generated bytecode or bad it execute.

@pult
seems like your answer is for issue #224