summaryrefslogtreecommitdiff
path: root/tests/test_wcsncat_n_eq_buf.c
blob: e516842bd2601e7d360d8a0bca3904714738a3d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "common.h"

#include <wchar.h>

int main(int argc, char** argv) {
  wchar_t buffer[8] = {0};
  wcsncat(buffer, L"12345", 5);
  printf("%ls\n", buffer);

  /* n == buffer capacity but overflow due to existing content.
   * buffer has 5 wchars, src L"ABC" (len 3): 5+3+1 = 9 > 8 → overflow. */
  CHK_FAIL_START
  wcsncat(buffer, L"ABC", 8);
  CHK_FAIL_END

  printf("%ls\n", buffer);
  return ret;
}