From e8f6840471eabee2f3c01006cb5a4e3815c6c4a9 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Sat, 4 Sep 2021 17:53:43 +0300 Subject: [PATCH] AK+LibRegex: Disable construction of views from temporary Strings --- AK/StringView.h | 2 ++ AK/Utf8View.h | 2 ++ Userland/Libraries/LibRegex/RegexMatch.h | 2 ++ 3 files changed, 6 insertions(+) diff --git a/AK/StringView.h b/AK/StringView.h index f98b18ff55..f67bab6196 100644 --- a/AK/StringView.h +++ b/AK/StringView.h @@ -48,6 +48,8 @@ public: StringView(const String&); StringView(const FlyString&); + explicit StringView(String&&) = delete; + [[nodiscard]] constexpr bool is_null() const { return !m_characters; } [[nodiscard]] constexpr bool is_empty() const { return m_length == 0; } diff --git a/AK/Utf8View.h b/AK/Utf8View.h index 306634de85..ed91e39b67 100644 --- a/AK/Utf8View.h +++ b/AK/Utf8View.h @@ -58,6 +58,8 @@ public: explicit Utf8View(const char*); ~Utf8View() = default; + explicit Utf8View(String&&) = delete; + const StringView& as_string() const { return m_string; } Utf8CodePointIterator begin() const; diff --git a/Userland/Libraries/LibRegex/RegexMatch.h b/Userland/Libraries/LibRegex/RegexMatch.h index 71cf3f1f1e..00004c2e3f 100644 --- a/Userland/Libraries/LibRegex/RegexMatch.h +++ b/Userland/Libraries/LibRegex/RegexMatch.h @@ -54,6 +54,8 @@ public: { } + explicit RegexStringView(String&&) = delete; + StringView const& string_view() const { return m_view.get();