]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid infloops in help-fns--analyze-function with aliases
authorLars Ingebrigtsen <larsi@gnus.org>
Thu, 13 Jan 2022 08:42:36 +0000 (09:42 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Thu, 13 Jan 2022 08:49:19 +0000 (09:49 +0100)
* lisp/help-fns.el (help-fns--analyze-function): Use
function-alias-p to avoid infloops.

lisp/help-fns.el
test/lisp/help-fns-tests.el

index d408efeeb9e3fc464effdc4871f6276260ea1ae5..e000a68a823d8c35bc374a58bb8f99d7f513ea15 100644 (file)
@@ -829,11 +829,7 @@ Returns a list of the form (REAL-FUNCTION DEF ALIASED REAL-DEF)."
                                               (symbol-name function)))))))
         (real-def (cond
                     ((and aliased (not (subrp def)))
-                     (let ((f real-function))
-                       (while (and (fboundp f)
-                                   (symbolp (symbol-function f)))
-                         (setq f (symbol-function f)))
-                       f))
+                     (car (function-alias-p real-function t)))
                    ((subrp def) (intern (subr-name def)))
                     (t def))))
 
index 6ee7b4f3eb1b01fa8dc53c8f472bdb51bb051f84..4df8e3c9ef638cbd01ddd304caed96df51f4835b 100644 (file)
@@ -177,4 +177,13 @@ Return first line of the output of (describe-function-1 FUNC)."
     (should-not (find-lisp-object-file-name help-fns--test-var 'defface))
     (should-not (find-lisp-object-file-name help-fns--test-var 1))))
 
+(ert-deftest help-fns--analyze-function-recursive ()
+  (defalias 'help-fns--a 'help-fns--b)
+  (should (equal (help-fns--analyze-function 'help-fns--a)
+                 '(help-fns--a help-fns--b t help-fns--b)))
+  ;; Make a loop and see that it doesn't infloop.
+  (defalias 'help-fns--b 'help-fns--a)
+  (should (equal (help-fns--analyze-function 'help-fns--a)
+                 '(help-fns--a help-fns--b t help-fns--b))))
+
 ;;; help-fns-tests.el ends here