View Issue Details

IDProjectCategoryView StatusLast Update
0002115JEDI VCL00 JVCL Componentspublic2005-08-10 03:18
ReporteranonymousAssigned Toobones 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version 
Target VersionFixed in Version3.10 
Summary0002115: JvInterpreter: Array to array assignment leads to Access Violation
Descriptionin 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".
TagsNo tags attached.

Activities

maxp

2004-09-06 02:38

reporter   ~0005196

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).

obones

2005-08-10 03:18

administrator   ~0007765

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.

Issue History

Date Modified Username Field Change
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