From: Lars Ingebrigtsen Date: Thu, 13 Jan 2022 08:42:36 +0000 (+0100) Subject: Avoid infloops in help-fns--analyze-function with aliases X-Git-Tag: emacs-29.0.90~3100 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d30fde6b0ccc02eada1f43e0b4cc1873e42f14d2;p=emacs.git Avoid infloops in help-fns--analyze-function with aliases * lisp/help-fns.el (help-fns--analyze-function): Use function-alias-p to avoid infloops. --- 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