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.
This commit is contained in:
Nico Weber 2020-10-06 11:09:28 -04:00 committed by Andreas Kling
parent fa5217ff4f
commit 21ac343211
Notes: sideshowbarker 2024-07-19 02:00:33 +09:00

View file

@ -89,7 +89,7 @@ public:
private:
URL m_url;
StringView m_name;
String m_name;
};
class Preformatted : public Line {