فهرست منبع

aasmtai: added tai_string.Create(ansistring)

Also prevent range check errors for empty strings
Jonas Maebe 3 سال پیش
والد
کامیت
ac89cfc6c7
1فایلهای تغییر یافته به همراه15 افزوده شده و 1 حذف شده
  1. 15 1
      compiler/aasmtai.pas

+ 15 - 1
compiler/aasmtai.pas

@@ -601,6 +601,7 @@ interface
           { extra len so the string can contain an \0 }
           len : longint;
           constructor Create(const _str : string);
+          constructor Create(const _str : ansistring);
           constructor Create_pchar(_str : pchar;length : longint);
           destructor Destroy;override;
           constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
@@ -2401,11 +2402,24 @@ implementation
           typ:=ait_string;
           len:=length(_str);
           getmem(str,len+1);
-          move(_str[1],str^,len);
+          if len>0 then
+            move(_str[1],str^,len);
           str[len]:=#0;
        end;
 
 
+     constructor tai_string.Create(const _str: ansistring);
+       begin
+         inherited Create;
+         typ:=ait_string;
+         len:=length(_str);
+         getmem(str,len+1);
+         if len>0 then
+           move(_str[1],str^,len);
+         str[len]:=#0;
+       end;
+
+
     constructor tai_string.Create_pchar(_str : pchar;length : longint);
        begin
           inherited Create;