From 7b09a37a895ab2d428d1ab0786aa262ef82efba2 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 27 Sep 2011 09:31:12 -0700 Subject: [PATCH] * coding.c (Ffind_operation_coding_system): Avoid subscript error. --- src/ChangeLog | 1 + src/coding.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index 7b09cb744a3..4f1edc95668 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -172,6 +172,7 @@ Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (consume_chars): Rewrite to avoid calculating an address outside buffer. (Ffind_operation_coding_system): NATNUMP can eval its arg twice. + Don't access memory outside of the args array. (Fdefine_coding_system_internal): Check for charset-id overflow. (ENCODE_ISO_CHARACTER): Use unsigned, not int, to store the unsigned result of ENCODE_CHAR. diff --git a/src/coding.c b/src/coding.c index 25ac0e9764c..e8765aea96d 100644 --- a/src/coding.c +++ b/src/coding.c @@ -9291,7 +9291,7 @@ usage: (find-operation-coding-system OPERATION ARGUMENTS...) */) if (!SYMBOLP (operation) || (target_idx = Fget (operation, Qtarget_idx), !NATNUMP (target_idx))) error ("Invalid first argument"); - if (nargs < 1 + XFASTINT (target_idx)) + if (nargs <= 1 + XFASTINT (target_idx)) error ("Too few arguments for operation `%s'", SDATA (SYMBOL_NAME (operation))); target = args[XFASTINT (target_idx) + 1]; -- 2.39.2