brintos

brintos / llvm-project-archived public Read only

0
0
Text · 573 B · 9480671 Raw
17 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__ ((unsigned)1)8 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