gabr42 / gabr42/GpDelphiUnits

Bug in TDSiRegistry.WriteBinary on Delphi 2009 or higher

Open
#2 0 comments 0 reactions 0 assignees View on GitHub
auto-migrated Priority-Medium Type-Defect
Dominant language
Pascal
Stars
190
Forks
63
PR merge metrics
No merged PRs in 30d

Description

```
What steps will reproduce the problem?

Compile and run this code:

{$APPTYPE CONSOLE}
uses
Windows, SysUtils, DSiWin32;
var
S, S1: string;
DSiReg: TDSiRegistry;

begin
DSiReg := TDSiRegistry.Create;
S := '0123456789';
DSiReg.RootKey:=HKEY_CURRENT_USER;

if DSiReg.OpenKey('Software\_Test', True) then
DSiReg.WriteBinary('TESTKEY', S);

S1 := DSiReg.ReadBinary('TESTKEY', '123');
WriteLn(S1);
FreeAndNil(DSiReg);
end.

What is the expected output?
0123456789
What do you see instead?
01234

What version of the product are you using? On what operating system?
Windows7 x32, Delphi 2009 or higher, DSiWin32 1.59b

Please provide any additional information below.

Fix:
Change line #1972 to
WriteBinaryData(name, pointer(data)^, Length(data)*SizeOf(data[1]));
```

Original issue reported on code.google.com by `d.atama...@gmail.com` on 5 Dec 2010 at 10:21

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at line 1972 in the TDSiRegistry.WriteBinary implementation and compare it with the Delphi 2009 or higher reproduction in the issue. Run the provided Windows registry example and verify that reading TESTKEY returns 0123456789 rather than 01234. Done means the supplied regression case produces the expected full string.

Written by the indexing model from the issue text.

Assessment

Domain
operating-systems
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.