Signal error when keyword/arg list is malformed

* src/data.c (syms_of_data): Add Qmalformed_keyword_arg_list
error symbol.

* src/process.c (Fmake_process, Fmake_pipe_process)
(Fserial_process_configure, Fmake_serial_process)
(Fmake_network_process): Signal Qmalformed_keyword_arg_list when
the argument list length is odd.
* src/sound.c (parse_sound): Also here..
* src/w32fns.c (Fw32_notification_notify): ..and here.

(Bug#75584)
This commit is contained in:
Robert Pluim 2025-01-20 18:43:00 +01:00
parent 64d314e0f6
commit 14e686e6cc
5 changed files with 22 additions and 1 deletions

View file

@ -4020,6 +4020,7 @@ syms_of_data (void)
DEFSYM (Qinvalid_function, "invalid-function");
DEFSYM (Qwrong_number_of_arguments, "wrong-number-of-arguments");
DEFSYM (Qmalformed_keyword_arg_list, "malformed-keyword-arg-list");
DEFSYM (Qno_catch, "no-catch");
DEFSYM (Qend_of_file, "end-of-file");
DEFSYM (Qarith_error, "arith-error");
@ -4119,6 +4120,8 @@ syms_of_data (void)
PUT_ERROR (Qinvalid_function, error_tail, "Invalid function");
PUT_ERROR (Qwrong_number_of_arguments, error_tail,
"Wrong number of arguments");
PUT_ERROR (Qmalformed_keyword_arg_list, error_tail,
"Keyword lacks a corresponding value");
PUT_ERROR (Qno_catch, error_tail, "No catch for tag");
PUT_ERROR (Qend_of_file, error_tail, "End of file during parsing");

View file

@ -4911,6 +4911,15 @@ extern Lisp_Object safe_funcall (ptrdiff_t, Lisp_Object*);
#define safe_calln(...) \
CALLMANY (safe_funcall, ((Lisp_Object []) {__VA_ARGS__}))
INLINE void
CHECK_KEYWORD_ARGS (ptrdiff_t nargs)
{
/* Used to check if a list of keyword/value pairs is missing a
value. */
if (nargs & 1)
xsignal0 (Qmalformed_keyword_arg_list);
}
extern void init_eval (void);
extern void syms_of_eval (void);
extern void prog_ignore (Lisp_Object);

View file

@ -1822,6 +1822,7 @@ usage: (make-process &rest ARGS) */)
if (nargs == 0)
return Qnil;
CHECK_KEYWORD_ARGS (nargs);
/* Save arguments for process-contact and clone-process. */
contact = Flist (nargs, args);
@ -2431,6 +2432,7 @@ usage: (make-pipe-process &rest ARGS) */)
if (nargs == 0)
return Qnil;
CHECK_KEYWORD_ARGS (nargs);
contact = Flist (nargs, args);
@ -3066,6 +3068,8 @@ usage: (serial-process-configure &rest ARGS) */)
Lisp_Object contact = Qnil;
Lisp_Object proc = Qnil;
CHECK_KEYWORD_ARGS (nargs);
contact = Flist (nargs, args);
proc = plist_get (contact, QCprocess);
@ -3170,6 +3174,7 @@ usage: (make-serial-process &rest ARGS) */)
if (nargs == 0)
return Qnil;
CHECK_KEYWORD_ARGS (nargs);
contact = Flist (nargs, args);
@ -3971,6 +3976,7 @@ usage: (make-network-process &rest ARGS) */)
if (nargs == 0)
return Qnil;
CHECK_KEYWORD_ARGS (nargs);
/* Save arguments for process-contact and clone-process. */
contact = Flist (nargs, args);

View file

@ -359,9 +359,11 @@ sound_warning (const char *msg)
static bool
parse_sound (Lisp_Object sound, Lisp_Object *attrs)
{
/* SOUND must be a list starting with the symbol `sound'. */
/* SOUND must be a list starting with the symbol `sound' followed by a
number of keyword/value argument pairs. */
if (!CONSP (sound) || !EQ (XCAR (sound), Qsound))
return 0;
CHECK_KEYWORD_ARGS (list_length (sound) - 1);
sound = XCDR (sound);
attrs[SOUND_FILE] = plist_get (sound, QCfile);

View file

@ -10655,6 +10655,7 @@ usage: (w32-notification-notify &rest PARAMS) */)
if (nargs == 0 || !pfnShell_NotifyIconW)
return Qnil;
CHECK_KEYWORD_ARGS (nargs);
arg_plist = Flist (nargs, args);