From abfbeb17e56bd9abc275de0f7ace6c197e00e3bf Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Mon, 21 Oct 2024 02:10:44 +0300 Subject: fixed EOL conversion on UTF-8 texts * The old bug of saving gchar in gints, so teco_eol_reader_t::last_char could become negative. * When converting from an UTF-8 text with CRLF linebreaks, we could have data loss and corruptions. * On strings ending in UTF-8 characters, teco_eol_reader_t::offset would overflow, resulting in invalid reads and potentially insertion of data garbage. I observed this with G~ on Gtk. * Test cased updated. Couldn't reproduce the bug with the test suite, though. --- src/eol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/eol.c b/src/eol.c index 0063bbd..3439869 100644 --- a/src/eol.c +++ b/src/eol.c @@ -239,7 +239,7 @@ teco_eol_reader_convert(teco_eol_reader_t *ctx, gchar **ret, gsize *data_len, GE else if (ctx->eol_style != SC_EOL_CR) ctx->eol_style_inconsistent = TRUE; } - ctx->last_char = buffer[i]; + ctx->last_char = (guchar)buffer[i]; break; } } -- cgit v1.2.3