[clang][bytecode] Check for block pointers in __builtin_strlen() (#187988)

This commit is contained in:
Timm Baeder 2026-03-23 09:35:19 +01:00 committed by GitHub
parent 9687ef3693
commit cda88c253c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View File

@ -357,6 +357,9 @@ static bool interp__builtin_strlen(InterpState &S, CodePtr OpPC,
if (!CheckLive(S, OpPC, StrPtr, AK_Read))
return false;
if (!StrPtr.isBlockPointer())
return false;
if (!CheckDummy(S, OpPC, StrPtr.block(), AK_Read))
return false;

View File

@ -19,3 +19,6 @@ void f2() { __builtin_memchr(f2, 0, 1); }
_Static_assert(__atomic_is_lock_free(4, (void*)2), ""); // both-error {{not an integral constant expression}}
_Static_assert(__builtin_strlen((void*)0 + 1) == 2, ""); // both-error {{not an integral constant expression}} \
// both-note {{cannot perform pointer arithmetic on null pointer}}