cxflag203/superobject

64-bit bug report and fix

GoogleCodeExporter opened this issue · 0 comments

The code below crashes or produces Out Of Memory error when compiled with 
Delphi XE6 or XE7 64-bit compiler on Windows 7.

type
  TMy = class
    arr: array of integer;
  end;

begin
  TMy.FromJson( SO('{"arr":[]}'));
end.


The bug is caused by passing the address of an Integer variable to 
DynArraySetLength which expects an address of a NativeInteger variable.

Fix:

--- superobject.pas 
+++ superobject.pas 
@@ -6141,7 +6141,7 @@

   procedure FromDynArray;
   var
-    i: Integer;
+    i: NativeInt;
     p: Pointer;
     pb: PByte;
     val: TValue;

Original issue reported on code.google.com by gerasi...@gmail.com on 11 Mar 2015 at 2:04