Browse Source

* readstring first nil size check, then type check. Otherwise, working Delphi code (indy9) would fail

git-svn-id: trunk@1051 -
marco 20 years ago
parent
commit
85b5480fd7
1 changed files with 12 additions and 10 deletions
  1. 12 10
      fcl/inc/registry.pp

+ 12 - 10
fcl/inc/registry.pp

@@ -328,17 +328,19 @@ Var
 
 
 begin
 begin
   GetDataInfo(Name,Info);
   GetDataInfo(Name,Info);
-  If Not (Info.RegData in [rdString,rdExpandString]) then
-    Raise ERegistryException.CreateFmt(SInvalidRegType, [Name]);
-  SetLength(Result,Info.DataSize);
-  If Info.DataSize>0 then
+  if info.datasize>0 then
     begin
     begin
-    If StringSizeIncludesNull then
-      SetLength(Result, Info.DataSize-1)
-    else
-      SetLength(Result, Info.DataSize);
-    GetData(Name,@Result[1],Info.DataSize,Info.RegData);
-    end;
+     If Not (Info.RegData in [rdString,rdExpandString]) then
+       Raise ERegistryException.CreateFmt(SInvalidRegType, [Name]);
+     SetLength(Result,Info.DataSize);
+     If StringSizeIncludesNull then
+       SetLength(Result, Info.DataSize-1)
+     else
+       SetLength(Result, Info.DataSize);
+     GetData(Name,@Result[1],Info.DataSize,Info.RegData);
+   end
+  else
+    result:='';
 end;
 end;
 
 
 function TRegistry.ReadTime(const Name: string): TDateTime;
 function TRegistry.ReadTime(const Name: string): TDateTime;