[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master d30fde6b0c 2/3: Avoid infloops in help-fns--analyze-function with
From: |
Lars Ingebrigtsen |
Subject: |
master d30fde6b0c 2/3: Avoid infloops in help-fns--analyze-function with aliases |
Date: |
Thu, 13 Jan 2022 03:49:27 -0500 (EST) |
branch: master
commit d30fde6b0ccc02eada1f43e0b4cc1873e42f14d2
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Avoid infloops in help-fns--analyze-function with aliases
* lisp/help-fns.el (help-fns--analyze-function): Use
function-alias-p to avoid infloops.
---
lisp/help-fns.el | 6 +-----
test/lisp/help-fns-tests.el | 9 +++++++++
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index d408efeeb9..e000a68a82 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 6ee7b4f3eb..4df8e3c9ef 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