From 0af182baa2f35d91b8dfaf0b5a8fef06b77dd03a Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Wed, 28 Apr 2021 11:32:44 -0400 Subject: applets/web: Fix a use-after-free when passing in the URL string The URL string was being deleted before being used, leading to a use-after-free occurring when it is used afterwards. Fix this by taking the string by const ref to extend its lifetime, ensuring it doesn't get deleted before use. --- src/yuzu/main.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/yuzu/main.cpp') diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 5f6cdc0c6..2fd38a851 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -574,8 +574,8 @@ void GMainWindow::SoftwareKeyboardExit() { software_keyboard = nullptr; } -void GMainWindow::WebBrowserOpenWebPage(std::string_view main_url, std::string_view additional_args, - bool is_local) { +void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url, + const std::string& additional_args, bool is_local) { #ifdef YUZU_USE_QT_WEB_ENGINE if (disable_web_applet) { @@ -596,13 +596,15 @@ void GMainWindow::WebBrowserOpenWebPage(std::string_view main_url, std::string_v loading_progress.setRange(0, 3); loading_progress.setValue(0); - if (is_local && !Common::FS::Exists(std::string(main_url))) { + if (is_local && !Common::FS::Exists(main_url)) { loading_progress.show(); auto future = QtConcurrent::run([this] { emit WebBrowserExtractOfflineRomFS(); }); while (!future.isFinished()) { QCoreApplication::processEvents(); + + std::this_thread::sleep_for(std::chrono::milliseconds(1)); } } -- cgit v1.2.3