]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
more: guarantee space for multibyte
authorKarel Zak <kzak@redhat.com>
Thu, 1 Aug 2013 14:41:50 +0000 (16:41 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 1 Aug 2013 15:03:27 +0000 (17:03 +0200)
.. to make the code more robust.

Signed-off-by: Karel Zak <kzak@redhat.com>
text-utils/more.c

index 9af15b3ff4c5307f81392451a2c430aac9776391..ac35acc0bd16250fb4929354bbc3324a42b124e3 100644 (file)
@@ -1030,6 +1030,12 @@ int get_line(register FILE *f, int *length)
 
                if (column >= Mcol && fold_opt)
                        break;
+#ifdef HAVE_WIDECHAR
+               if (use_mbc_buffer_flag == 0 && p >= &Line[LineLen - 1 - 4])
+                       /* don't read another char if there is no space for
+                        * whole multibyte sequence */
+                       break;
+#endif
                c = Getc(f);
        }
        if (column >= Mcol && Mcol > 0) {