llvm-project/clang/test/Analysis/buffer-overlap-decls.c
guillem-bartrina-sonarsource 668f56d003
[analyzer] CStringChecker: Fix crash in CheckOverlap when arguments are not pointers (#160511)
https://github.com/llvm/llvm-project/blob/main/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp#L675-L678
mistakenly assumes that target expressions are of pointer type.
`CheckOverlap` has multiple call sites, most of which do not verify this
assumption. Therefore, the simplest solution is to verify it just before
that point.
2025-09-29 13:37:47 +00:00

24 lines
538 B
C

// RUN: %clang_analyze_cc1 -verify %s -Wno-incompatible-library-redeclaration \
// RUN: -analyzer-checker=alpha.unix.cstring.BufferOverlap
// expected-no-diagnostics
typedef typeof(sizeof(int)) size_t;
void memcpy(int dst, int src, size_t size);
void test_memcpy_proxy() {
memcpy(42, 42, 42); // no-crash
}
void strcpy(int dst, char *src);
void test_strcpy_proxy() {
strcpy(42, (char *)42); // no-crash
}
void strxfrm(int dst, char *src, size_t size);
void test_strxfrm_proxy() {
strxfrm(42, (char *)42, 42); // no-crash
}