[clang] [clang][bytecode] Avoid crash in constexpr wcslen on invalid argument… (PR #177891)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 26 02:39:57 PST 2026
================
@@ -367,10 +367,14 @@ static bool interp__builtin_strlen(InterpState &S, CodePtr OpPC,
unsigned ElemSize = StrPtr.getFieldDesc()->getElemSize();
if (ID == Builtin::BI__builtin_wcslen || ID == Builtin::BIwcslen) {
- [[maybe_unused]] const ASTContext &AC = S.getASTContext();
- assert(ElemSize == AC.getTypeSizeInChars(AC.getWCharType()).getQuantity());
+ const ASTContext &AC = S.getASTContext();
+ unsigned WCharSize = AC.getTypeSizeInChars(AC.getWCharType()).getQuantity();
+ if (ElemSize != WCharSize) {
+ return false;
+ }
----------------
tbaederr wrote:
```suggestion
if (ElemSize != WCharSize)
return false;
```
https://github.com/llvm/llvm-project/pull/177891
More information about the cfe-commits
mailing list