Browse Source

* Small safety precaution

Michaël Van Canneyt 3 years ago
parent
commit
042eb7e8c1
1 changed files with 2 additions and 2 deletions
  1. 2 2
      rtl/objpas/classes/streams.inc

+ 2 - 2
rtl/objpas/classes/streams.inc

@@ -414,7 +414,7 @@ begin
     if r>High(Longint) then r:=High(Longint);
     if r>High(Longint) then r:=High(Longint);
     r:=Read(PByte(@Buffer)[t],r);
     r:=Read(PByte(@Buffer)[t],r);
     inc(t,r);
     inc(t,r);
-  until (t=Count) or (r<=0);
+  until (t>=Count) or (r<=0);
   if (t<Count) then
   if (t<Count) then
     raise EReadError.Create(SReadError);
     raise EReadError.Create(SReadError);
 end;
 end;
@@ -591,7 +591,7 @@ begin
     if w>High(Longint) then w:=High(Longint);
     if w>High(Longint) then w:=High(Longint);
     w:=Write(PByte(@Buffer)[t],w);
     w:=Write(PByte(@Buffer)[t],w);
     inc(t,w);
     inc(t,w);
-  until (t=count) or (w<=0);
+  until (t>=count) or (w<=0);
   if (t<Count) then
   if (t<Count) then
     raise EWriteError.Create(SWriteError);
     raise EWriteError.Create(SWriteError);
 end;
 end;