From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Romain Francoise Newsgroups: gmane.emacs.devel Subject: `with-output-to-string' leaks buffers Date: Sat, 20 Sep 2008 00:26:17 +0200 Organization: orebokech dot com Message-ID: <878wtnlqly.fsf@elegiac.orebokech.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1221863195 25392 80.91.229.12 (19 Sep 2008 22:26:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 19 Sep 2008 22:26:35 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Sep 20 00:27:31 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KgoRn-00030V-FL for ged-emacs-devel@m.gmane.org; Sat, 20 Sep 2008 00:27:31 +0200 Original-Received: from localhost ([127.0.0.1]:34354 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KgoQl-0005T8-SR for ged-emacs-devel@m.gmane.org; Fri, 19 Sep 2008 18:26:27 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KgoQg-0005T3-Br for emacs-devel@gnu.org; Fri, 19 Sep 2008 18:26:22 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KgoQe-0005Sn-IB for emacs-devel@gnu.org; Fri, 19 Sep 2008 18:26:21 -0400 Original-Received: from [199.232.76.173] (port=40361 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KgoQe-0005Sk-DB for emacs-devel@gnu.org; Fri, 19 Sep 2008 18:26:20 -0400 Original-Received: from smtp8-g19.free.fr ([212.27.42.65]:59779) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KgoQd-0002So-Sf for emacs-devel@gnu.org; Fri, 19 Sep 2008 18:26:20 -0400 Original-Received: from smtp8-g19.free.fr (localhost [127.0.0.1]) by smtp8-g19.free.fr (Postfix) with ESMTP id BF4BF32A7BF for ; Sat, 20 Sep 2008 00:26:17 +0200 (CEST) Original-Received: from elegiac.orebokech.com (home.orebokech.com [82.67.41.165]) by smtp8-g19.free.fr (Postfix) with ESMTP id A281632A7B6 for ; Sat, 20 Sep 2008 00:26:17 +0200 (CEST) Original-Received: by elegiac.orebokech.com (Postfix, from userid 1000) id 6F21C3B15D; Sat, 20 Sep 2008 00:26:17 +0200 (CEST) X-Face: }9mYu,e_@+e!`Z-P5kVXa3\_b:hdJ"B)ww[&=b<2=awG:GOIM List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:103977 Archived-At: 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 * 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.