[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs-26 3a22097: Fix valgrind report in call-interactivel
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] emacs-26 3a22097: Fix valgrind report in call-interactively |
Date: |
Sat, 6 Jan 2018 11:25:24 -0500 (EST) |
branch: emacs-26
commit 3a22097cf68761aa106a5455409b7eec689efd88
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>
Fix valgrind report in call-interactively
* src/callint.c (Fcall_interactively): Don't try to access more
bytes than are available in the interactive spec. (Bug#30004)
---
src/callint.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/src/callint.c b/src/callint.c
index ef22851..e4491e9 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -774,10 +774,23 @@ invoke it. If KEYS is omitted or nil, the return value of
if anyone tries to define one here. */
case '+':
default:
- error ("Invalid control letter `%c' (#o%03o, #x%04x) in interactive
calling string",
- STRING_CHAR ((unsigned char *) tem),
- (unsigned) STRING_CHAR ((unsigned char *) tem),
- (unsigned) STRING_CHAR ((unsigned char *) tem));
+ {
+ /* How many bytes are left unprocessed in the specs string?
+ (Note that this excludes the trailing null byte.) */
+ ptrdiff_t bytes_left = SBYTES (specs) - (tem - string);
+ unsigned letter;
+
+ /* If we have enough bytes left to treat the sequence as a
+ character, show that character's codepoint; otherwise
+ show only its first byte. */
+ if (bytes_left >= BYTES_BY_CHAR_HEAD (*((unsigned char *) tem)))
+ letter = STRING_CHAR ((unsigned char *) tem);
+ else
+ letter = *((unsigned char *) tem);
+
+ error ("Invalid control letter `%c' (#o%03o, #x%04x) in interactive
calling string",
+ (int) letter, letter, letter);
+ }
}
if (varies[i] == 0)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] emacs-26 3a22097: Fix valgrind report in call-interactively,
Eli Zaretskii <=