summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorsin-ack <sin-ack@users.noreply.github.com>2022-07-11 20:55:39 +0000
committerAndreas Kling <kling@serenityos.org>2022-07-12 23:11:35 +0200
commit5744211001d6f0775c0b281e908db6ddd83eaf4d (patch)
tree1d873630b3ee2eb79af32b6eda968aacd7b5896f /AK
parentd16544100f5b4c9b1e4848d510675de5b3924350 (diff)
downloadserenity-5744211001d6f0775c0b281e908db6ddd83eaf4d.zip
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.
Diffstat (limited to 'AK')
-rw-r--r--AK/StringView.h5
1 files changed, 0 insertions, 5 deletions
diff --git a/AK/StringView.h b/AK/StringView.h
index a64b7b5e87..457fefbf63 100644
--- a/AK/StringView.h
+++ b/AK/StringView.h
@@ -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())