all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* `with-output-to-string' leaks buffers
@ 2008-09-19 22:26 Romain Francoise
  2008-09-22 23:14 ` Glenn Morris
  2008-09-23  0:27 ` Stefan Monnier
  0 siblings, 2 replies; 5+ messages in thread
From: Romain Francoise @ 2008-09-19 22:26 UTC (permalink / raw)
  To: emacs-devel

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  <romain@orebokech.com>

	* 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.




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-09-23 18:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-19 22:26 `with-output-to-string' leaks buffers Romain Francoise
2008-09-22 23:14 ` Glenn Morris
2008-09-23  0:27 ` Stefan Monnier
2008-09-23 17:29   ` Romain Francoise
2008-09-23 18:00     ` Chong Yidong

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.