1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:57:35 +00:00

Presenter: Fix a crash in loading untitled presentations

The Presentation::title() and Presentation::author() functions return a
StringView to the title/author defined in the json file or a default
value. Previously, this would return a StringView to already-freed
memory and crash the application when setting the window title. This
commit fixes that issue :^)
This commit is contained in:
Arda Cinar 2022-12-13 15:11:19 +03:00 committed by Tim Flynn
parent e305b32d9a
commit 9d9a6b6b64

View file

@ -30,12 +30,16 @@ void Presentation::append_slide(Slide slide)
StringView Presentation::title() const
{
return m_metadata.get("title"sv).value_or("Untitled Presentation"sv);
if (m_metadata.contains("title"sv))
return m_metadata.get("title"sv)->view();
return "Untitled Presentation"sv;
}
StringView Presentation::author() const
{
return m_metadata.get("author"sv).value_or("Unknown Author"sv);
if (m_metadata.contains("author"sv))
return m_metadata.get("author"sv)->view();
return "Unknown Author"sv;
}
void Presentation::next_frame()