From 60416d39cda3ebf336bdb77487d3b7d8d429f1b6 Mon Sep 17 00:00:00 2001 From: Gregory Heytings Date: Mon, 12 Dec 2022 22:16:18 +0000 Subject: [PATCH] Check that arguments are strings in pcomplete-here-using-help * lisp/pcomplete.el (pcomplete-here-using-help): Check that pcomplete-args are strings before applying string operations on them. Fixes bug#59956 and bug#60021. --- lisp/pcomplete.el | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lisp/pcomplete.el b/lisp/pcomplete.el index 4e3a88bbda8..c63c490bcaa 100644 --- a/lisp/pcomplete.el +++ b/lisp/pcomplete.el @@ -1449,12 +1449,18 @@ pcomplete-here-using-help The switches are obtained by calling `pcomplete-from-help' with COMMAND and ARGS as arguments." (while (cond - ((string= "--" (pcomplete-arg 1)) + ((let ((arg (pcomplete-arg 1))) + (if (stringp arg) + (string= "--" arg))) (while (pcomplete-here (pcomplete-entries)))) - ((pcomplete-match "\\`--[^=]+=\\(.*\\)" 0) + ((let ((arg (pcomplete-arg 0))) + (if (stringp arg) + (pcomplete-match "\\`--[^=]+=\\(.*\\)" 0))) (pcomplete-here (pcomplete-entries) (pcomplete-match-string 1 0))) - ((string-prefix-p "-" (pcomplete-arg 0)) + ((let ((arg (pcomplete-arg 0))) + (if (stringp arg) + (string-prefix-p "-" arg))) (pcomplete-here (apply #'pcomplete-from-help command args))) (t (pcomplete-here* (pcomplete-entries)))))) -- 2.35.1