summaryrefslogtreecommitdiff
path: root/tests/test_wcsncat_n_eq_buf.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_wcsncat_n_eq_buf.c')
-rw-r--r--tests/test_wcsncat_n_eq_buf.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_wcsncat_n_eq_buf.c b/tests/test_wcsncat_n_eq_buf.c
new file mode 100644
index 0000000..e516842
--- /dev/null
+++ b/tests/test_wcsncat_n_eq_buf.c
@@ -0,0 +1,18 @@
1#include "common.h"
2
3#include <wchar.h>
4
5int main(int argc, char** argv) {
6 wchar_t buffer[8] = {0};
7 wcsncat(buffer, L"12345", 5);
8 printf("%ls\n", buffer);
9
10 /* n == buffer capacity but overflow due to existing content.
11 * buffer has 5 wchars, src L"ABC" (len 3): 5+3+1 = 9 > 8 → overflow. */
12 CHK_FAIL_START
13 wcsncat(buffer, L"ABC", 8);
14 CHK_FAIL_END
15
16 printf("%ls\n", buffer);
17 return ret;
18}