From fc6d051dfdddc13835548537d025e760ba186b5b Mon Sep 17 00:00:00 2001 From: Max Wipfli Date: Tue, 29 Jun 2021 16:46:16 +0200 Subject: AK+Everywhere: Add and use static APIs for LexicalPath The LexicalPath instance methods dirname(), basename(), title() and extension() will be changed to return StringView const& in a further commit. Due to this, users creating temporary LexicalPath objects just to call one of those getters will recieve a StringView const& pointing to a possible freed buffer. To avoid this, static methods for those APIs have been added, which will return a String by value to avoid those problems. All cases where temporary LexicalPath objects have been used as described above haven been changed to use the static APIs. --- Userland/Libraries/LibWeb/Loader/FrameLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Userland/Libraries/LibWeb/Loader') diff --git a/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp b/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp index 8e6065deb6..6db5f9b13c 100644 --- a/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp +++ b/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp @@ -81,7 +81,7 @@ static bool build_image_document(DOM::Document& document, const ByteBuffer& data auto title_element = document.create_element("title"); head_element->append_child(title_element); - auto basename = LexicalPath(document.url().path()).basename(); + auto basename = LexicalPath::basename(document.url().path()); auto title_text = adopt_ref(*new DOM::Text(document, String::formatted("{} [{}x{}]", basename, bitmap->width(), bitmap->height()))); title_element->append_child(title_text); -- cgit v1.2.3