Browse Source

* ansistring constants now also get a trailing #0 (bug reported by
Thomas Schatzl)

Jonas Maebe 25 years ago
parent
commit
3ca96dd897
1 changed files with 11 additions and 3 deletions
  1. 11 3
      compiler/ptconst.pas

+ 11 - 3
compiler/ptconst.pas

@@ -496,10 +496,14 @@ unit ptconst;
                             { third write use count (set to -1 for safety ) }
                             { third write use count (set to -1 for safety ) }
                             consts^.concat(new(pai_const,init_32bit(-1)));
                             consts^.concat(new(pai_const,init_32bit(-1)));
                             consts^.concat(new(pai_label,init(ll)));
                             consts^.concat(new(pai_label,init(ll)));
-                            getmem(ca,strlength+1);
+                            getmem(ca,strlength+2);
                             move(strval^,ca^,strlength);
                             move(strval^,ca^,strlength);
+                            { The terminating #0 to be stored in the .data section (JM) }
                             ca[strlength]:=#0;
                             ca[strlength]:=#0;
-                            consts^.concat(new(pai_string,init_length_pchar(ca,strlength)));
+                            { End of the PChar. The memory has to be allocated because in }
+                            { tai_string.done, there is a freemem(len+1) (JM)             } 
+                            ca[strlength+1]:=#0;
+                            consts^.concat(new(pai_string,init_length_pchar(ca,strlength+1)));
                           end;
                           end;
                      end;
                      end;
                  end;
                  end;
@@ -790,7 +794,11 @@ unit ptconst;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.67  2000-05-17 17:10:06  peter
+  Revision 1.68  2000-06-06 13:06:17  jonas
+    * ansistring constants now also get a trailing #0 (bug reported by
+      Thomas Schatzl)
+
+  Revision 1.67  2000/05/17 17:10:06  peter
     * add support for loading of typed const strings with resourcestrings,
     * add support for loading of typed const strings with resourcestrings,
       made the loading also a bit more generic
       made the loading also a bit more generic