From 898af394fcbde57ca3d08e3648b62fe0b3f41911 Mon Sep 17 00:00:00 2001 From: Pip Cet Date: Wed, 6 May 2020 11:08:29 +0000 Subject: [PATCH] Require at least two arguments for Fapply * src/eval.c (Fapply): Require at least two arguments, to prevent crashes when (apply nil) is evaluated. * lisp/progmodes/ebrowse.el (ebrowse-tags-loop-continue): Provide two arguments to `apply'. * lisp/svg.el (svg--eval-path-command): Provide two arguments to `apply'. * lisp/simple.el (primitive-undo): Provide two arguments to `apply'. --- lisp/net/telnet.el | 3 ++- lisp/progmodes/ebrowse.el | 3 ++- lisp/simple.el | 2 +- lisp/svg.el | 3 ++- src/eval.c | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lisp/net/telnet.el b/lisp/net/telnet.el index e8c0c1bbdf..b0350eacbf 100644 --- a/lisp/net/telnet.el +++ b/lisp/net/telnet.el @@ -109,7 +109,8 @@ telnet-revert-buffer (revert-buffer ignore-auto noconfirm)) (if (or noconfirm (yes-or-no-p (format "Restart connection? "))) - (apply telnet-connect-command)))) + (apply (car telnet-connect-command) + (cdr telnet-connect-command))))) (defun telnet-c-z () (interactive) diff --git a/lisp/progmodes/ebrowse.el b/lisp/progmodes/ebrowse.el index 1c9e805f03..f052266b1a 100644 --- a/lisp/progmodes/ebrowse.el +++ b/lisp/progmodes/ebrowse.el @@ -3612,7 +3612,8 @@ ebrowse-tags-loop-continue (when first-time (ebrowse-tags-next-file first-time tree-buffer) (goto-char (point-min))) - (while (not (apply ebrowse-tags-loop-call)) + (while (not (apply (car ebrowse-tags-loop-call) + (cdr ebrowse-tags-loop-call))) (ebrowse-tags-next-file) (message "Scanning file `%s'..." buffer-file-name) (goto-char (point-min)))) diff --git a/lisp/simple.el b/lisp/simple.el index b5ba05426f..9a96ce0013 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -2778,7 +2778,7 @@ primitive-undo (error "Changes to be undone by function different from announced")) (set-marker start-mark nil) (set-marker end-mark nil)) - (apply fun-args)) + (apply (car fun-args) (cdr fun-args))) (unless (eq currbuff (current-buffer)) (error "Undo function switched buffer")) (setq did-apply t))) diff --git a/lisp/svg.el b/lisp/svg.el index 7aadbc2359..982e2b0965 100644 --- a/lisp/svg.el +++ b/lisp/svg.el @@ -437,7 +437,8 @@ svg--eval-path-command #'svg--elliptical-arc-command) (extended-command (append command (list :default-relative default-relative)))) - (mapconcat 'prin1-to-string (apply extended-command) " "))) + (mapconcat 'prin1-to-string (apply (car extended-command) + (cdr extended-command)) " "))) (defun svg-path (svg commands &rest args) "Add the outline of a shape to SVG according to COMMANDS. diff --git a/src/eval.c b/src/eval.c index 014905ce6d..1b9fd90482 100644 --- a/src/eval.c +++ b/src/eval.c @@ -2358,7 +2358,7 @@ eval_sub (Lisp_Object form) return val; } -DEFUN ("apply", Fapply, Sapply, 1, MANY, 0, +DEFUN ("apply", Fapply, Sapply, 2, MANY, 0, doc: /* Call FUNCTION with our remaining args, using our last arg as list of args. Then return the value FUNCTION returns. Thus, (apply \\='+ 1 2 \\='(3 4)) returns 10. -- 2.26.2