• R/O
  • HTTP
  • SSH
  • HTTPS

yash: Commit

Repository for the main codebase


Commit MetaInfo

Revisão6a60fd9747d0170c396322e9466734e7c6567b54 (tree)
Hora2023-11-12 13:14:20
AutorWATANABE Yuki <magicant@wond...>
CommiterWATANABE Yuki

Mensagem de Log

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.

Fixes https://github.com/magicant/yash/issues/33

Mudança Sumário

Diff

--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,9 @@ History of Yash
77 - Fixed the bug where the "typeset -fp" built-in prints parameter
88 expansions of the form `${foo:/bar/baz}` with a redundant `#` flag
99 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.
1013
1114
1215 ======================================================================
--- a/NEWS.ja
+++ b/NEWS.ja
@@ -6,6 +6,9 @@ Yash 更新履歴
66 - Cygwin で開けるファイル記述子の数を増やした
77 - "typeset -fp" で `${foo:/bar/baz}` 形式のパラメータ展開が誤って
88 `${foo:/#bar/baz}` と出力されるバグを修正
9+ - `emacs-capitalize-word` 行編集コマンドの実行時にカーソルの後に
10+ キャピタライズの対象となる文字がない場合に誤動作してクラッシュする
11+ こともあるバグを修正
912
1013
1114 ======================================================================
--- a/lineedit/editing.c
+++ b/lineedit/editing.c
@@ -3199,8 +3199,10 @@ void cmd_emacs_capitalize_word(wchar_t c __attribute__((unused)))
31993199 do {
32003200 while (*s != L'\0' && !iswalnum(*s))
32013201 s++;
3202- *s = towupper(*s);
3203- s++;
3202+ if (*s != L'\0') {
3203+ *s = towupper(*s);
3204+ s++;
3205+ }
32043206 while (*s != L'\0' && iswalnum(*s))
32053207 s++;
32063208 } while (*s != L'\0' && --count > 0);
Show on old repository browser