Repository for the main codebase
Revisão | 6a60fd9747d0170c396322e9466734e7c6567b54 (tree) |
---|---|
Hora | 2023-11-12 13:14:20 |
Autor | WATANABE Yuki <magicant@wond...> |
Commiter | WATANABE Yuki |
Don't overrun buffer in emacs-capitalize-word
If the emacs-capitalize-word line-editing command is invoked with the
cursor at the end of the buffer, the command should not update the
buffer. We need a boundary check before updating the buffer and
incrementing the cursor position.
@@ -7,6 +7,9 @@ History of Yash | ||
7 | 7 | - Fixed the bug where the "typeset -fp" built-in prints parameter |
8 | 8 | expansions of the form `${foo:/bar/baz}` with a redundant `#` flag |
9 | 9 | like `${foo:/#bar/baz}`. |
10 | + - Fixed the bug where the `emacs-capitalize-word` line-editing | |
11 | + command misbehaves and possibly crashes the shell if there is no | |
12 | + word following the cursor to be capitalized. | |
10 | 13 | |
11 | 14 | |
12 | 15 | ====================================================================== |
@@ -6,6 +6,9 @@ Yash 更新履歴 | ||
6 | 6 | - Cygwin で開けるファイル記述子の数を増やした |
7 | 7 | - "typeset -fp" で `${foo:/bar/baz}` 形式のパラメータ展開が誤って |
8 | 8 | `${foo:/#bar/baz}` と出力されるバグを修正 |
9 | + - `emacs-capitalize-word` 行編集コマンドの実行時にカーソルの後に | |
10 | + キャピタライズの対象となる文字がない場合に誤動作してクラッシュする | |
11 | + こともあるバグを修正 | |
9 | 12 | |
10 | 13 | |
11 | 14 | ====================================================================== |
@@ -3199,8 +3199,10 @@ void cmd_emacs_capitalize_word(wchar_t c __attribute__((unused))) | ||
3199 | 3199 | do { |
3200 | 3200 | while (*s != L'\0' && !iswalnum(*s)) |
3201 | 3201 | s++; |
3202 | - *s = towupper(*s); | |
3203 | - s++; | |
3202 | + if (*s != L'\0') { | |
3203 | + *s = towupper(*s); | |
3204 | + s++; | |
3205 | + } | |
3204 | 3206 | while (*s != L'\0' && iswalnum(*s)) |
3205 | 3207 | s++; |
3206 | 3208 | } while (*s != L'\0' && --count > 0); |