Streams: bug fixes
[nikiroo-utils.git] / src / be / nikiroo / utils / streams / BufferedOutputStream.java
index 5f7e6ebc7011d4df33c10e95356ad1a91f08b925..2071d0c3b5d68623457808efb7167c9e265dc651 100644 (file)
@@ -184,8 +184,10 @@ public class BufferedOutputStream extends OutputStream {
         *             in case of I/O error
         */
        protected void flush(boolean includingSubStream) throws IOException {
-               out.write(buffer, start, stop - start);
-               bytesWritten += (stop - start);
+               if (stop > start) {
+                       out.write(buffer, start, stop - start);
+                       bytesWritten += (stop - start);
+               }
                start = 0;
                stop = 0;