Browse Source

* fix buffer handling in flush

git-svn-id: trunk@10080 -
peter 17 years ago
parent
commit
f5131f591a
1 changed files with 5 additions and 5 deletions
  1. 5 5
      packages/paszlib/src/zstream.pp

+ 5 - 5
packages/paszlib/src/zstream.pp

@@ -217,11 +217,6 @@ var err:smallint;
 begin
   {Compress remaining data still in internal zlib data buffers.}
   repeat
-    err:=deflate(Fstream,Z_FINISH);
-    if err=Z_STREAM_END then
-      break;
-    if err<>Z_OK then
-      raise Ecompressionerror.create(zerror(err));
     if Fstream.avail_out=0 then
       begin
         { Flush the buffer to the stream and update progress }
@@ -232,6 +227,11 @@ begin
         Fstream.next_out:=Fbuffer;
         Fstream.avail_out:=bufsize;
       end;
+    err:=deflate(Fstream,Z_FINISH);
+    if err=Z_STREAM_END then
+      break;
+    if (err<>Z_OK) then
+      raise Ecompressionerror.create(zerror(err));
   until false;
   if Fstream.avail_out<bufsize then
     begin