From 21ac34321135cfda01295357aaaa04576c9a3fa4 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Tue, 6 Oct 2020 11:09:28 -0400 Subject: [PATCH] LibGemini: Fix crash on Link lines without explicit link text Link::Link() does: if (m_name.is_null()) m_name = m_url.to_string(); This tries to set the link text to the link url if there's no explicit link text, but m_url.to_string() returns a temporary string object, and m_name was a StringView, so this ended pointing to invalid memory. This made the converted HTML contain garbage data as link text, which made LibWeb crash. (LibWeb probably shouldn't crash on links with garbage link text, but in this case it helped identify a bug, so let's keep that crash around since real web pages won't trigger it and it's kind of useful to find bugs like this one.) Makes gemini://rawtext.club/ no longer crash Browser. --- Libraries/LibGemini/Document.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/LibGemini/Document.h b/Libraries/LibGemini/Document.h index ad623563f9..4bebc94303 100644 --- a/Libraries/LibGemini/Document.h +++ b/Libraries/LibGemini/Document.h @@ -89,7 +89,7 @@ public: private: URL m_url; - StringView m_name; + String m_name; }; class Preformatted : public Line {