From 495fd0788ecb4aeda6ee3b47fbfc000f70368948 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Mon, 19 Jan 2009 15:19:54 +0100 Subject: [PATCH] Fix regression in handling of data for non-UTF-8 locales The bug was introduced in 65498141015b6070cf5c9b5704039389dba76e90 where the the IO API was changed from using stdio to 'raw' file descriptors. Part of the change removed the need for cutting the ending newline from the input line in update_view(). This caused the resulting iconv output buffer to not be NUL terminated since the input string no longer contained an ending NULL byte. Reported by Pavel Roskin. --- NEWS | 1 + tig.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 2ac62ca..2dda520 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,7 @@ Improvements: Bug fixes: - Tree view: fix memory corruption bug when updating. + - Fix regression for non-UTF-8 locales corrupting the view data. tig-0.13 -------- diff --git a/tig.c b/tig.c index 101d0b7..b16fe24 100644 --- a/tig.c +++ b/tig.c @@ -2707,7 +2707,7 @@ update_view(struct view *view) if (opt_iconv != ICONV_NONE) { ICONV_CONST char *inbuf = line; - size_t inlen = linelen; + size_t inlen = linelen + 1; char *outbuf = out_buffer; size_t outlen = sizeof(out_buffer); -- 2.30.2