Code

Fix regression in handling of data for non-UTF-8 locales
authorJonas Fonseca <fonseca@diku.dk>
Mon, 19 Jan 2009 14:19:54 +0000 (15:19 +0100)
committerJonas Fonseca <fonseca@diku.dk>
Mon, 19 Jan 2009 14:39:04 +0000 (15:39 +0100)
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
tig.c

diff --git a/NEWS b/NEWS
index 2ac62caba5b82f9d6637ec2aab24d0b00f4bf714..2dda5202420c40a32e36c2e85be304a60e8d9caa 100644 (file)
--- 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 101d0b794f57dbcc12fae93b5f67c516230b748c..b16fe244d0fd2d9b26d4208fd99c9ffaecf4b338 100644 (file)
--- 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);