Browse Source

* Protected some Move()'s by 'if' clauses so that the Move won't be
executed when the length would be 0. Otherwise, the corresponding
routines might get an RTE when compiled with $R+.

sg 25 years ago
parent
commit
7319e91a20
3 changed files with 27 additions and 8 deletions
  1. 9 3
      rtl/objpas/syspch.inc
  2. 10 3
      rtl/objpas/sysstr.inc
  3. 8 2
      rtl/objpas/sysutils.inc

+ 9 - 3
rtl/objpas/syspch.inc

@@ -38,8 +38,9 @@ type
 function StrPas(Str: PChar): string;
 begin
   SetLength(result, StrLen(Str));
-  Move(Str^, result[1], Length(result));
-end ;
+  if Length(Result) > 0 then
+    Move(Str^, result[1], Length(result));
+end;
 
 {  StrAlloc allocates a buffer of Size + 4
    the size of the allocated buffer is stored at result - 4
@@ -118,7 +119,12 @@ end ;
 
 {
   $Log$
-  Revision 1.2  2000-07-13 11:33:51  michael
+  Revision 1.3  2000-11-23 11:04:26  sg
+  * Protected some Move()'s by 'if' clauses so that the Move won't be
+    executed when the length would be 0. Otherwise, the corresponding
+    routines might get an RTE when compiled with $R+.
+
+  Revision 1.2  2000/07/13 11:33:51  michael
   + removed logs
  
 }

+ 10 - 3
rtl/objpas/sysstr.inc

@@ -929,13 +929,15 @@ Var S,F : String;
 
 begin
   Setlength(F,fmtlen);
-  Move(fmt,F[1],fmtlen);
+  if fmtlen > 0 then
+    Move(fmt,F[1],fmtlen);
   S:=Format (F,Args);
   If Length(S)>Buflen then
     Result:=Length(S)
   else
     Result:=Buflen;
-  Move(S[1],Buffer,Result);
+  if Result > 0 then
+    Move(S[1],Buffer,Result);
 end;
 
 Procedure FmtStr(Var Res: String; Const Fmt : String; Const args: Array of const);
@@ -1267,7 +1269,12 @@ const
 
 {
   $Log$
-  Revision 1.6  2000-11-13 14:41:20  marco
+  Revision 1.7  2000-11-23 11:04:26  sg
+  * Protected some Move()'s by 'if' clauses so that the Move won't be
+    executed when the length would be 0. Otherwise, the corresponding
+    routines might get an RTE when compiled with $R+.
+
+  Revision 1.6  2000/11/13 14:41:20  marco
    * Unix renamefest for defines
 
   Revision 1.5  2000/09/30 15:51:41  michael

+ 8 - 2
rtl/objpas/sysutils.inc

@@ -255,7 +255,8 @@ begin
     end;
   If Len>Size then
     Len:=Size;
-  Move(S[1],Buffer^,Len);
+  if Len > 0 then
+    Move(S[1],Buffer^,Len);
   Result:=Len;
 end;
 
@@ -289,7 +290,12 @@ end;
 
 {
   $Log$
-  Revision 1.2  2000-08-20 15:46:46  peter
+  Revision 1.3  2000-11-23 11:04:26  sg
+  * Protected some Move()'s by 'if' clauses so that the Move won't be
+    executed when the length would be 0. Otherwise, the corresponding
+    routines might get an RTE when compiled with $R+.
+
+  Revision 1.2  2000/08/20 15:46:46  peter
     * sysutils.pp moved to target and merged with disk.inc, filutil.inc
 
 }