diff options
| author | Gabriel Ford <gabe@fordltc.net> | 2025-05-29 14:29:16 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-29 13:29:16 -0500 |
| commit | b28bbee539625f9bcbf128e8da400d1d55b499ff (patch) | |
| tree | 2bf575ffd02ba17813c0021d042a9df351b785c3 /src/nvim | |
| parent | f82219c490a5a2bec749f4811f5e8ef95ec20b95 (diff) | |
| download | rneovim-b28bbee539625f9bcbf128e8da400d1d55b499ff.tar.gz rneovim-b28bbee539625f9bcbf128e8da400d1d55b499ff.tar.bz2 rneovim-b28bbee539625f9bcbf128e8da400d1d55b499ff.zip | |
fix(terminal): skip setting `string_initial` to false on no-op (#34176)
Problem:
Currently undefined behavior can occur when `string_fragment()` is
called with `OSC_COMMAND`. This is because when the state changes to
`OSC_COMMAND`, `string_initial` is set to true. Then in some cases,
directly after this `string_initial` will be set back to false before
the on_osc callback is called, this leads to `term_settermprop()` never
initializing the title.
Solution:
In all of the no-op cases in `string_fragment()` currently, we continue
to the end of the function where `vt->parser.string_initial` is set to
false. This change returns in the no-op cases instead since in these
cases the string has not yet been terminated and sent to the callback.
Note:
This change also adds a test with a byte sequence from the file
in #34028 that caused nvim to crash. This byte sequences is the shortest
sequence I could trim down from that file that still would trigger the
crash. There are also two other tests I added which validate that
setting the title with OSC-0 and OSC-2 still works.
Fixes: #34028
Diffstat (limited to 'src/nvim')
| -rw-r--r-- | src/nvim/vterm/parser.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/nvim/vterm/parser.c b/src/nvim/vterm/parser.c index 79d348f2c1..f5f33c18c2 100644 --- a/src/nvim/vterm/parser.c +++ b/src/nvim/vterm/parser.c @@ -122,7 +122,7 @@ static void string_fragment(VTerm *vt, const char *str, size_t len, bool final) case CSI_INTERMED: case OSC_COMMAND: case DCS_COMMAND: - break; + return; } vt->parser.string_initial = false; |