View Issue Details

IDProjectCategoryView StatusLast Update
0005766JEDI VCL00 JVCL Componentspublic2012-09-10 14:15
ReporterKiriakosAssigned ToAHUser 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product VersionDaily / GIT 
Target VersionFixed in Version3.46 
Summary0005766: 64-bt incompatibility in AppIniStorage
DescriptionAppIniStorage stores float properties using the following code.

procedure TJvCustomAppIniStorage.DoWriteFloat(const Path: string; Value: Extended);
...
  WriteValue(Section, Key, BufToBinStr(@Value, SizeOf(Value)));
end;

and read it with


function TJvCustomAppIniStorage.DoReadFloat(const Path: string; Default: Extended): Extended;
...
 if BinStrToBuf(Value, @Result, SizeOf(Result)) <> SizeOf(Result) then
...

The problem is the Extended in CPUX64 is identical to double, so if an ini file was written by a 32-bit application it will not be read correctly by a 64-bit application and vice-versa.

Suggested fix:
Replace DoReadFloat, DoWriteFloat with following:

function TJvCustomAppIniStorage.DoReadFloat(const Path: string; Default: Extended): Extended;
var
  Section: string;
  Key: string;
  Value: string;
  {$IFDEF CPUX64}
  TempValue : Extended80;
  {$ENDIF CPUX64}
begin
  SplitKeyPath(Path, Section, Key);
  if ValueExists(Section, Key) then
  begin
    Value := ReadValue(Section, Key);
    {$IFDEF CPUX64}
    if BinStrToBuf(Value, @TempValue, SizeOf(TempValue)) <> SizeOf(TempValue) then
      Result := Default
    else
      try
        Result := TempValue;
      except
        Result := Default;
      end;
    {$ELSE CPUX64}
    if BinStrToBuf(Value, @Result, SizeOf(Result)) <> SizeOf(Result) then
      Result := Default;
    {$ENDIF CPUX64}
  end
  else
    Result := Default;
end;

procedure TJvCustomAppIniStorage.DoWriteFloat(const Path: string; Value: Extended);
var
  Section: string;
  Key: string;
  {$IFDEF CPUX64}
  TempValue : Extended80;
  {$ENDIF CPUX64}
begin
  SplitKeyPath(Path, Section, Key);
  {$IFDEF CPUX64}
  TempValue := Value;
  WriteValue(Section, Key, BufToBinStr(@TempValue, SizeOf(TempValue)));
  {$ELSE CPUX64}
  WriteValue(Section, Key, BufToBinStr(@Value, SizeOf(Value)));
  {$ENDIF CPUX64}
end;

This has been tested and works fine.
TagsNo tags attached.

Activities

AHUser

2012-01-19 21:31

developer   ~0019326

Fixed in svn revision 13191

Issue History

Date Modified Username Field Change
2012-01-12 21:39 Kiriakos New Issue
2012-01-19 21:31 AHUser Note Added: 0019326
2012-01-19 21:31 AHUser Status new => resolved
2012-01-19 21:31 AHUser Fixed in Version => Daily / SVN
2012-01-19 21:31 AHUser Resolution open => fixed
2012-01-19 21:31 AHUser Assigned To => AHUser
2012-09-10 14:15 obones Fixed in Version Daily / SVN => 3.46