Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0005766 [JEDI VCL] 00 JVCL Components major always 2012-01-12 21:39 2012-09-10 14:15
Reporter Kiriakos View Status public  
Assigned To AHUser
Priority normal Resolution fixed  
Status resolved   Product Version Daily / GIT
Summary 0005766: 64-bt incompatibility in AppIniStorage
Description AppIniStorage 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.
Additional Information
Tags No tags attached.
Attached Files

- Relationships

-  Notes
(0019326)
AHUser (developer)
2012-01-19 21:31

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


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker