summaryrefslogtreecommitdiff
path: root/gl/tests/test-mbsalign.c
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2010-03-19 21:40:05 +0000
committerPádraig Brady <P@draigBrady.com>2010-03-19 21:40:05 +0000
commitc872a1d8a51617c2ec76423da6f76ef2208f30d9 (patch)
tree379df526baf20883e9497bfe574ec9b051d48c88 /gl/tests/test-mbsalign.c
parentdfe0d336a00940c8e13c24b6d5d7485a2d7310b0 (diff)
downloadcoreutils-c872a1d8a51617c2ec76423da6f76ef2208f30d9.tar.xz
maint: mbsalign: fix an edge case where we truncate too much
* gl/lib/mbsalign.c (mbsalign): Ensure the temporary destination buffer is big enough, as it may need to be bigger than the source buffer in the presence of single byte non printable chars. * gl/tests/test-mbsalign.c (main): Add a test to trigger the issue.
Diffstat (limited to 'gl/tests/test-mbsalign.c')
-rw-r--r--gl/tests/test-mbsalign.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/gl/tests/test-mbsalign.c b/gl/tests/test-mbsalign.c
index 9f8935732..1d894831e 100644
--- a/gl/tests/test-mbsalign.c
+++ b/gl/tests/test-mbsalign.c
@@ -87,6 +87,13 @@ main (void)
width = 4; /* cells */
n = mbsalign ("¹²³", dest, 0, &width, MBS_ALIGN_LEFT, 0);
ASSERT (width == 3);
+
+ /* Test case where output is larger than input
+ (as tab converted to multi byte replacement char). */
+ width = 4;
+ n = mbsalign ("t\tés" /* 6 including NUL */ , dest, sizeof dest,
+ &width, MBS_ALIGN_LEFT, 0);
+ ASSERT (n == 7);
}
return 0;