Assigning "int64" and "qword" variables to and from "OleVariant" is implemented wrong.
Original Reporter info from Mantis: SnoopyDog
-
Reporter name: Martin R.
Original Reporter info from Mantis: SnoopyDog
- Reporter name: Martin R.
Description:
Assigning "int64" and "qword" variables to and from "OleVariant" is implemented wrong in "variant.inc"
Assigning an int64 or qword to OleVariant looses the higher 4 bytes because it calls "VariantManager.VarFromInt" for both cases. And in the other direction, "VarToInt64" and "VarToWord64" are exchanged.
Steps to reproduce:
var V : OleVariant;
I64 : Int64;
I64 := 7513860751762750;
V := I64; // This sets V to 151004478
I64 := V; // Value of I64 is now 151004478
Additional information:
variants.pp => Add:
procedure sysolevarfromint64(var Dest : olevariant; const Source : Int64);
begin
DoVarClearIfComplex(TVarData(Dest));
with TVarData(Dest) do begin
vint64 := Source;
vType := varint64;
end;
end;
procedure sysolevarfromqword(var Dest : olevariant; const Source : QWord);
begin
DoVarClearIfComplex(TVarData(Dest));
with TVarData(Dest) do begin
vqword := Source;
vType := varqword;
end;
end;
SysVariantManager
.....
olevarfromint64: @sysolevarfromint64;
olevarfromqword: @sysolevarfromqword;
--------------------------------------
variant.inc => change
operator :=(const source : olevariant) dest : qword;{$ifdef SYSTEMINLINE}inline;{$endif}
begin
dest:=variantmanager.vartoword64(variant(tvardata(source)));
end;
operator :=(const source : olevariant) dest : int64;{$ifdef SYSTEMINLINE}inline;{$endif}
begin
dest:=variantmanager.vartoint64(variant(tvardata(source)));
end;
operator :=(const source : qword) dest : olevariant;{$ifdef SYSTEMINLINE}inline;{$endif}
begin
variantmanager.olevarfromqword(dest,source);
end;
operator :=(const source : int64) dest : olevariant;{$ifdef SYSTEMINLINE}inline;{$endif}
begin
variantmanager.olevarfromint64(dest,source);
end;
Mantis conversion info:
- Mantis ID: 35150
- Version: 3.0.4
- Fixed in version: 3.3.1
- Fixed in revision: 41571 (#9a9c6a3f)
- Monitored by: » Cyrax (Cyrax)