diff options
| author | Eli Zaretskii | 2018-01-06 18:23:52 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2018-01-06 18:23:52 +0200 |
| commit | 3a22097cf68761aa106a5455409b7eec689efd88 (patch) | |
| tree | 5057db935c3470c6c1aab3c6d0d1634d851fdc47 /src | |
| parent | d5f1c87bfed04c3cd84a27f599d1b38233e88816 (diff) | |
| download | emacs-3a22097cf68761aa106a5455409b7eec689efd88.tar.gz emacs-3a22097cf68761aa106a5455409b7eec689efd88.zip | |
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)
Diffstat (limited to 'src')
| -rw-r--r-- | src/callint.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/callint.c b/src/callint.c index ef228517f17..e4491e9085a 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 | |||
| 774 | if anyone tries to define one here. */ | 774 | if anyone tries to define one here. */ |
| 775 | case '+': | 775 | case '+': |
| 776 | default: | 776 | default: |
| 777 | error ("Invalid control letter `%c' (#o%03o, #x%04x) in interactive calling string", | 777 | { |
| 778 | STRING_CHAR ((unsigned char *) tem), | 778 | /* How many bytes are left unprocessed in the specs string? |
| 779 | (unsigned) STRING_CHAR ((unsigned char *) tem), | 779 | (Note that this excludes the trailing null byte.) */ |
| 780 | (unsigned) STRING_CHAR ((unsigned char *) tem)); | 780 | ptrdiff_t bytes_left = SBYTES (specs) - (tem - string); |
| 781 | unsigned letter; | ||
| 782 | |||
| 783 | /* If we have enough bytes left to treat the sequence as a | ||
| 784 | character, show that character's codepoint; otherwise | ||
| 785 | show only its first byte. */ | ||
| 786 | if (bytes_left >= BYTES_BY_CHAR_HEAD (*((unsigned char *) tem))) | ||
| 787 | letter = STRING_CHAR ((unsigned char *) tem); | ||
| 788 | else | ||
| 789 | letter = *((unsigned char *) tem); | ||
| 790 | |||
| 791 | error ("Invalid control letter `%c' (#o%03o, #x%04x) in interactive calling string", | ||
| 792 | (int) letter, letter, letter); | ||
| 793 | } | ||
| 781 | } | 794 | } |
| 782 | 795 | ||
| 783 | if (varies[i] == 0) | 796 | if (varies[i] == 0) |