From 867f7da0179c6b77c729247f16e403c37b0322fa Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Mon, 16 Oct 2023 15:35:11 +0330 Subject: [PATCH] AK: Avoid nullptr deref in DeprecatedString(DeprecatedFlyString const&) Prior to this commit, constructing a DS from a null DFS would cause a nullptr deref, which broke (at least) Profiler. This commit converts the null DFS to an empty DS, avoiding the nullptr deref (until DFS loses its null state, or we decide to not make it convertible to a DS). --- AK/DeprecatedString.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AK/DeprecatedString.cpp b/AK/DeprecatedString.cpp index 74184daa49..408243d430 100644 --- a/AK/DeprecatedString.cpp +++ b/AK/DeprecatedString.cpp @@ -374,7 +374,7 @@ DeprecatedString escape_html_entities(StringView html) } DeprecatedString::DeprecatedString(DeprecatedFlyString const& string) - : m_impl(*string.impl()) + : m_impl(*(string.impl() ?: &StringImpl::the_empty_stringimpl())) { }