]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix `uniquify-managed' unbounded growth
authorLars Ingebrigtsen <larsi@gnus.org>
Wed, 12 May 2021 15:36:24 +0000 (17:36 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Wed, 12 May 2021 15:36:24 +0000 (17:36 +0200)
* lisp/uniquify.el (uniquify-rationalize-file-buffer-names):
Protect against exponential `uniquify-managed' growth when
reverting several (more than two) buffers that have the same file
name (bug#36877).

lisp/uniquify.el

index 7cc01687f4947efd1c0676bbf6cd6f96345f5a86..ffb5ecc902476a2df68b6cf8f1168f6d99ed0c16 100644 (file)
@@ -246,7 +246,14 @@ this rationalization."
                              (if (buffer-live-p (uniquify-item-buffer item))
                                  item))
                            items)))
-         (setq fix-list (append fix-list items))))
+          ;; Other buffer's `uniquify-managed' lists may share
+          ;; elements.  Ensure that we don't add these elements more
+          ;; than once to this buffer's `uniquify-managed' list.
+          (let ((new-items nil))
+            (dolist (item items)
+              (unless (memq item fix-list)
+                (push item new-items)))
+           (setq fix-list (append fix-list new-items)))))
       ;; selects buffers whose names may need changing, and others that
       ;; may conflict, then bring conflicting names together
       (uniquify-rationalize fix-list))))