Author: Timm Baeder Date: 2025-10-27T10:43:01+01:00 New Revision: 5d1e1cfa086a8ef7e9a74a41f5d626d4d20a3708
URL: https://github.com/llvm/llvm-project/commit/5d1e1cfa086a8ef7e9a74a41f5d626d4d20a3708 DIFF: https://github.com/llvm/llvm-project/commit/5d1e1cfa086a8ef7e9a74a41f5d626d4d20a3708.diff LOG: [clang][bytecode] Check memcmp for block pointers (#165070) We can't read from non-block pointers anyway. Fixes https://github.com/llvm/llvm-project/issues/165061 Added: Modified: clang/lib/AST/ByteCode/InterpBuiltin.cpp clang/test/AST/ByteCode/builtin-functions.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index d0b97a18e1815..839e84fd85bea 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -1941,6 +1941,9 @@ static bool interp__builtin_memcmp(InterpState &S, CodePtr OpPC, return true; } + if (!PtrA.isBlockPointer() || !PtrB.isBlockPointer()) + return false; + bool IsWide = (ID == Builtin::BIwmemcmp || ID == Builtin::BI__builtin_wmemcmp); diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp b/clang/test/AST/ByteCode/builtin-functions.cpp index 0b7d51be8d824..d8572ba722d69 100644 --- a/clang/test/AST/ByteCode/builtin-functions.cpp +++ b/clang/test/AST/ByteCode/builtin-functions.cpp @@ -1510,6 +1510,8 @@ namespace Memcmp { static_assert(f()); #endif + int unknown; + void foo(void) { unknown *= __builtin_memcmp(0, 0, 2); } } namespace Memchr { _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
