Browse Source

* fixed concat when s1 or s2 was nil

peter 26 years ago
parent
commit
e3836e3e31
1 changed files with 10 additions and 3 deletions
  1. 10 3
      rtl/inc/astrings.inc

+ 10 - 3
rtl/inc/astrings.inc

@@ -76,7 +76,8 @@ Function NewAnsiString(Len : Longint) : Pointer;
 Var
 Var
   P : Pointer;
   P : Pointer;
 begin
 begin
-  GetMem(P,Len+AnsiRecLen);
+  { Also add +1 for a terminating zero }
+  GetMem(P,Len+1+AnsiRecLen);
   If P<>Nil then
   If P<>Nil then
    begin
    begin
      PAnsiRec(P)^.Maxlen:=Len;    { Maximal length }
      PAnsiRec(P)^.Maxlen:=Len;    { Maximal length }
@@ -158,11 +159,14 @@ Var
   Size,Location : Longint;
   Size,Location : Longint;
   S3 : pointer;
   S3 : pointer;
 begin
 begin
+  S3:=nil;
   if (S1=Nil) then
   if (S1=Nil) then
     AnsiStr_Assign(S3,S2)
     AnsiStr_Assign(S3,S2)
+  else
+    if (S2=Nil) then
+      AnsiStr_Assign(S3,S1)
   else
   else
     begin
     begin
-       S3:=Nil;
        Size:=PAnsiRec(S2-FirstOff)^.Len;
        Size:=PAnsiRec(S2-FirstOff)^.Len;
        Location:=Length(AnsiString(S1));
        Location:=Length(AnsiString(S1));
        { Setlength takes case of uniqueness
        { Setlength takes case of uniqueness
@@ -760,7 +764,10 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.17  1999-04-06 11:23:58  peter
+  Revision 1.18  1999-04-08 10:19:55  peter
+    * fixed concat when s1 or s2 was nil
+
+  Revision 1.17  1999/04/06 11:23:58  peter
     * fixed insert on last char
     * fixed insert on last char
     * saver chararray 2 ansi
     * saver chararray 2 ansi