Skip to content

Commit

Permalink
fix memory leak in deflate stream
Browse files Browse the repository at this point in the history
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
John Foderaro committed Mar 18, 2011
1 parent 4bb325b commit 44b5270
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions deflate.cl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)))
Expand Down

0 comments on commit 44b5270

Please sign in to comment.