diff --git a/src/main/java/fr/wseduc/webutils/data/ZLib.java b/src/main/java/fr/wseduc/webutils/data/ZLib.java
index <HASH>..<HASH> 100644
--- a/src/main/java/fr/wseduc/webutils/data/ZLib.java
+++ b/src/main/java/fr/wseduc/webutils/data/ZLib.java
@@ -56,9 +56,14 @@ public class ZLib {
 		byte[] buffer = new byte[1024];
 		while (!inflater.finished()) {
 			int count = inflater.inflate(buffer);
-			outputStream.write(buffer, 0, count);
+			if (count > 0) {
+				outputStream.write(buffer, 0, count);
+			} else {
+				break;
+			}
 		}
 		outputStream.close();
+		inflater.end();
 		return outputStream.toByteArray();
 	}
defensive programming in Zlib Inflater