summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2022-01-13 09:42:36 +0100
committerLars Ingebrigtsen <larsi@gnus.org>2022-01-13 09:49:19 +0100
commitd30fde6b0ccc02eada1f43e0b4cc1873e42f14d2 (patch)
tree797cfda81ea51b405193b05b66dfa75981eb7acb
parentc8a2af3037c647bf6dd53f53af1b344e284f809b (diff)
downloademacs-d30fde6b0ccc02eada1f43e0b4cc1873e42f14d2.tar.gz
Avoid infloops in help-fns--analyze-function with aliases
* lisp/help-fns.el (help-fns--analyze-function): Use function-alias-p to avoid infloops.
-rw-r--r--lisp/help-fns.el6
-rw-r--r--test/lisp/help-fns-tests.el9
2 files changed, 10 insertions, 5 deletions
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index d408efeeb9e..e000a68a823 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -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))))
diff --git a/test/lisp/help-fns-tests.el b/test/lisp/help-fns-tests.el
index 6ee7b4f3eb1..4df8e3c9ef6 100644
--- a/test/lisp/help-fns-tests.el
+++ b/test/lisp/help-fns-tests.el
@@ -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