Project JEDI - Issue Tracker - JEDI VCL
Viewing Issue Advanced Details
2115 00 JVCL Components major always 2004-09-03 23:57 2005-08-10 03:18
anonymous  
obones  
normal  
resolved  
fixed  
none    
none 3.10  
0002115: JvInterpreter: Array to array assignment leads to Access Violation
in JvIntepreter code:

unit TestUnit;
function main: string;
var
  A, B: array[1..10] of integer;
begin
  A := B; // (*)
end;
end.

array to array assignment in Line (*) leads to AV on exit.
This is because JvInterpreterVarAssignment procedure in JvInterpreter.pas treats arrays incorrectly: instead of content copying it assigns array pointer. Note that record to record assignment is performed correctly in this procedure. I cannot propose a complete fix of this problem now but I suggest that it would be good to insert NotImplemented call into JvInterpreterVarAssignment proc:
....
....
procedure JvInterpreterVarAssignment(var Dest: Variant; const Source: Variant);
...
begin
  if TVarData(Source).VType = varArray then
  begin
    NotImplemented('array to array assignment ');
    //TVarData(Dest) := TVarData(Source) // access violation caused by this line
  end
  else
...
...

I believe that this "fix" will not influence other assignment logic of JvInterplreter, at least all JvInterpreter examples works with this "fix".
Issue History
2004-09-03 23:57 anonymous New Issue
2004-09-06 02:38 maxp Note Added: 0005196
2005-08-10 03:18 obones Status new => resolved
2005-08-10 03:18 obones Resolution open => fixed
2005-08-10 03:18 obones Assigned To => obones
2005-08-10 03:18 obones Note Added: 0007765

Notes
(0005196)
maxp   
2004-09-06 02:38   
Strictly speaking, JvInterpreterVarAssignment is not accurate for records too because it does not check if Dest and Source records both have an identical type. If one declared two variables of different records type, having different number of fields, an AV is very likely if Source record has more fields then Dest (see text of JvInterpreterVarAssignment in JvInterpreter.pas).
(0007765)
obones   
2005-08-10 03:18   
This is now fixed in CVS.
Please post new issues should you find ways to implement this and/or fix the problem mentionned in the note.