Browse Source

* Merging revisions r45444 from trunk:
------------------------------------------------------------------------
r45444 | michael | 2020-05-20 09:32:09 +0200 (Wed, 20 May 2020) | 1 line

* Fix bug ID #37118
------------------------------------------------------------------------

git-svn-id: branches/fixes_3_2@46587 -

michael 5 years ago
parent
commit
0a2f57724b
1 changed files with 4 additions and 1 deletions
  1. 4 1
      rtl/objpas/classes/streams.inc

+ 4 - 1
rtl/objpas/classes/streams.inc

@@ -529,7 +529,10 @@ end;
 Procedure THandleStream.SetSize(const NewSize: Int64);
 
 begin
-  FileTruncate(FHandle,NewSize);
+  // We set the position afterwards, because the size can also be larger.
+  if not FileTruncate(FHandle,NewSize) then
+    Raise EInOutError.Create(SStreamSetSize);
+  Position:=NewSize;
 end;