[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
`with-output-to-string' leaks buffers
From: |
Romain Francoise |
Subject: |
`with-output-to-string' leaks buffers |
Date: |
Sat, 20 Sep 2008 00:26:17 +0200 |
Shouldn't `with-output-to-string' reap the temporary buffer it
creates even if the code it wraps exits nonlocally?
(git.el installs a function in `after-save-hook' which uses this
macro around code that signals an error, and as a result I had a
little more than 250 *string-output* buffers slowing things down
after a few days of uptime...)
2008-09-19 Romain Francoise <address@hidden>
* subr.el (with-output-to-string): Make sure that the temporary
buffer gets killed.
Index: lisp/subr.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/subr.el,v
retrieving revision 1.606
diff -u -r1.606 subr.el
--- lisp/subr.el 7 Sep 2008 09:15:43 -0000 1.606
+++ lisp/subr.el 19 Sep 2008 21:56:40 -0000
@@ -2586,12 +2586,13 @@
(declare (indent 0) (debug t))
`(let ((standard-output
(get-buffer-create (generate-new-buffer-name " *string-output*"))))
- (let ((standard-output standard-output))
- ,@body)
- (with-current-buffer standard-output
- (prog1
- (buffer-string)
- (kill-buffer nil)))))
+ (unwind-protect
+ (progn
+ (let ((standard-output standard-output))
+ ,@body)
+ (with-current-buffer standard-output
+ (buffer-string)))
+ (kill-buffer standard-output))))
(defmacro with-local-quit (&rest body)
"Execute BODY, allowing quits to terminate BODY but not escape further.
- `with-output-to-string' leaks buffers,
Romain Francoise <=