Преглед изворни кода

* Fixed handling of zero-length strings (classes.inc: When converting
empty strings from text forms to binary forms; reader.inc: When reading
an empty string from a binary serialization)

sg пре 22 година
родитељ
комит
3b8e03aef6
2 измењених фајлова са 16 додато и 4 уклоњено
  1. 8 2
      fcl/inc/classes.inc
  2. 8 2
      fcl/inc/reader.inc

+ 8 - 2
fcl/inc/classes.inc

@@ -880,7 +880,8 @@ var
   procedure WriteString(s: String);
   procedure WriteString(s: String);
   begin
   begin
     Output.WriteByte(Length(s));
     Output.WriteByte(Length(s));
-    Output.Write(s[1], Length(s));
+    if Length(s) > 0 then
+      Output.Write(s[1], Length(s));
   end;
   end;
 
 
   procedure WriteInteger(value: LongInt);
   procedure WriteInteger(value: LongInt);
@@ -1189,7 +1190,12 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.10  2002-09-07 15:15:24  peter
+  Revision 1.11  2002-12-02 12:04:07  sg
+  * Fixed handling of zero-length strings (classes.inc: When converting
+    empty strings from text forms to binary forms; reader.inc: When reading
+    an empty string from a binary serialization)
+
+  Revision 1.10  2002/09/07 15:15:24  peter
     * old logs removed and tabs fixed
     * old logs removed and tabs fixed
 
 
   Revision 1.9  2002/07/16 13:32:51  florian
   Revision 1.9  2002/07/16 13:32:51  florian

+ 8 - 2
fcl/inc/reader.inc

@@ -194,7 +194,8 @@ var
 begin
 begin
   Read(i, 1);
   Read(i, 1);
   SetLength(Result, i);
   SetLength(Result, i);
-  Read(Pointer(@Result[1])^, i);
+  if i > 0 then
+    Read(Pointer(@Result[1])^, i);
 end;
 end;
 
 
 function TBinaryObjectReader.ReadString(StringType: TValueType): String;
 function TBinaryObjectReader.ReadString(StringType: TValueType): String;
@@ -1267,7 +1268,12 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.6  2002-09-07 15:15:25  peter
+  Revision 1.7  2002-12-02 12:04:07  sg
+  * Fixed handling of zero-length strings (classes.inc: When converting
+    empty strings from text forms to binary forms; reader.inc: When reading
+    an empty string from a binary serialization)
+
+  Revision 1.6  2002/09/07 15:15:25  peter
     * old logs removed and tabs fixed
     * old logs removed and tabs fixed
 
 
 }
 }