mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
AK: Remove StringView(char const*) :^)
This constructor relied on running strlen implicitly on its argument, thereby potentially causing out-of-bound reads (some of which were caught a few days ago). The removal of this constructor ensures that the caller must explicitly pass the size of the string by either: 1) Using operator""sv on literal strings; or 2) Calling strlen explicitly, making it clear that the size of the view is being calculated at runtime.
This commit is contained in:
parent
d16544100f
commit
5744211001
Notes:
sideshowbarker
2024-07-17 09:26:31 +09:00
Author: https://github.com/sin-ack Commit: https://github.com/SerenityOS/serenity/commit/5744211001 Pull-request: https://github.com/SerenityOS/serenity/pull/14555 Reviewed-by: https://github.com/Dexesttp ✅ Reviewed-by: https://github.com/kleinesfilmroellchen
1 changed files with 0 additions and 5 deletions
|
@ -33,11 +33,6 @@ public:
|
|||
{
|
||||
VERIFY(!Checked<uintptr_t>::addition_would_overflow((uintptr_t)characters, length));
|
||||
}
|
||||
ALWAYS_INLINE constexpr StringView(char const* cstring)
|
||||
: m_characters(cstring)
|
||||
, m_length(cstring ? __builtin_strlen(cstring) : 0)
|
||||
{
|
||||
}
|
||||
ALWAYS_INLINE StringView(ReadonlyBytes bytes)
|
||||
: m_characters(reinterpret_cast<char const*>(bytes.data()))
|
||||
, m_length(bytes.size())
|
||||
|
|
Loading…
Reference in a new issue