Permalink
Browse files

fix memory leak in deflate stream

Now allow zlib code to free space it had malloc'ed.

Are there user visible changes in this commit?  no

Is bootstrapping needed?   no

Are tests included for new features?  no

Tests run:  manual test watching vm size to verify fix

Change-Id: If988821daf4ffeaee1d58b4f75354ae866d74982
  • Loading branch information...
1 parent 4bb325b commit 44b5270ea8a1a8a29e808649d501f1b0768f5372 John Foderaro committed Mar 18, 2011
Showing with 9 additions and 0 deletions.
  1. +9 −0 deflate.cl
View
@@ -329,6 +329,10 @@ actual error:~% ~a" c)))
then (error "deflateInit2_ returned ~a" err)))
z-stream))
+(defun finish-z-stream (z-stream)
+ ;; free C resources controlled by zlib
+ (deflate-end z-stream))
+
(defmethod device-write ((p deflate-stream) buffer start end blocking)
@@ -477,6 +481,11 @@ actual error:~% ~a" c)))
(finish-zlib-compression p))
(free-deflate-buffer-resource (zlib-static-resources p))
+
+ (let ((z-stream (zlib-z-stream p)))
+ (if* (not (zerop z-stream))
+ then (finish-z-stream z-stream))
+ (setf (zlib-z-stream p) 0))
(if* (deflate-target-stream p)
then (force-output (deflate-target-stream p)))

0 comments on commit 44b5270

Please sign in to comment.