1 // RUN: %check_clang_tidy %s bugprone-not-null-terminated-result %t -- \ 2 // RUN: -- -std=c11 -I %S/Inputs/bugprone-not-null-terminated-result 3 4 #include "not-null-terminated-result-c.h" 5 6 #define __STDC_LIB_EXT1__ 1 7 #define __STDC_WANT_LIB_EXT1__ ((unsigned)1) 8 f(const char * src)9void f(const char *src) { 10 char dest[13]; 11 memcpy_s(dest, 13, src, strlen(src) - 1); 12 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the result from calling 'memcpy_s' is not null-terminated [bugprone-not-null-terminated-result] 13 // CHECK-FIXES: char dest[14]; 14 // CHECK-FIXES-NEXT: strncpy_s(dest, 14, src, strlen(src) - 1); 15 } 16 17