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