diff --git a/CHANGES b/CHANGES
index 17d4039eef320426bdfc402173aced6746248dd2..2ad7ca185864f0e49d2fea28281743731b3d64b8 100644
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,10 @@
 
                                   Changelog
 
+Daniel Stenberg (14 Feb 2009)
+- Andre Guibert de Bruet found and fixed a memory leak in the content encoding
+  code, which could happen on libz errors.
+
 Daniel Fandrich (12 Feb 2009)
 - Added support for Digest and NTLM authentication using GnuTLS.
 
diff --git a/RELEASE-NOTES b/RELEASE-NOTES
index 0661de35cfd94a671dce434427995c2ad1474762..59e44263506a80a71a386d62dd5e0bb2327abc09 100644
--- a/RELEASE-NOTES
+++ b/RELEASE-NOTES
@@ -31,6 +31,7 @@ This release includes the following bugfixes:
  o multi interface memory leak with CURLMOPT_MAXCONNECTS set
  o CURLINFO_CONTENT_LENGTH_DOWNLOAD size from file:// "transfers" with
    CURLOPT_NOBODY set true
+ o memory leak on some libz errors for content encodings
 
 This release includes the following known bugs:
 
@@ -41,6 +42,6 @@ advice from friends like these:
 
  Lisa Xu, Daniel Fandrich, Craig A West, Alexey Borzov, Sharad Gupta,
  Peter Sylvester, Chad Monroe, Markus Moeller, Yang Tse, Scott Cantor,
- Patrick Scott, Hidemoto Nakada, Jocelyn Jaubert
+ Patrick Scott, Hidemoto Nakada, Jocelyn Jaubert, Andre Guibert de Bruet
 
         Thanks! (and sorry if I forgot to mention someone)
diff --git a/lib/content_encoding.c b/lib/content_encoding.c
index 9cd5b07341ee941407a6b91974c629e831190dad..0de1c15d65ba97b265c1e812738f4a9522bb1672 100644
--- a/lib/content_encoding.c
+++ b/lib/content_encoding.c
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2007, 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -133,8 +133,9 @@ inflate_stream(struct connectdata *conn,
       /* some servers seem to not generate zlib headers, so this is an attempt
          to fix and continue anyway */
 
-      (void) inflateEnd(z);	/* don't care about the return code */
+      (void) inflateEnd(z);     /* don't care about the return code */
       if(inflateInit2(z, -MAX_WBITS) != Z_OK) {
+        free(decomp);
         return process_zlib_error(conn, z);
       }
       z->next_in = orig_in;