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/applets/web_browser.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/yuzu/applets/web_browser.h') diff --git a/src/yuzu/applets/web_browser.h b/src/yuzu/applets/web_browser.h index 47f960d69..7ad07409f 100644 --- a/src/yuzu/applets/web_browser.h +++ b/src/yuzu/applets/web_browser.h @@ -58,7 +58,7 @@ public: * @param main_url The url to the file. * @param additional_args Additional arguments appended to the main url. */ - void LoadLocalWebPage(std::string_view main_url, std::string_view additional_args); + void LoadLocalWebPage(const std::string& main_url, const std::string& additional_args); /** * Loads an external website. Cannot be used to load local urls. @@ -66,7 +66,7 @@ public: * @param main_url The url to the website. * @param additional_args Additional arguments appended to the main url. */ - void LoadExternalWebPage(std::string_view main_url, std::string_view additional_args); + void LoadExternalWebPage(const std::string& main_url, const std::string& additional_args); /** * Sets the background color of the web page. @@ -193,16 +193,17 @@ public: explicit QtWebBrowser(GMainWindow& parent); ~QtWebBrowser() override; - void OpenLocalWebPage(std::string_view local_url, std::function extract_romfs_callback_, + void OpenLocalWebPage(const std::string& local_url, + std::function extract_romfs_callback_, std::function callback_) const override; - void OpenExternalWebPage(std::string_view external_url, + void OpenExternalWebPage(const std::string& external_url, std::function callback_) const override; signals: - void MainWindowOpenWebPage(std::string_view main_url, std::string_view additional_args, + void MainWindowOpenWebPage(const std::string& main_url, const std::string& additional_args, bool is_local) const; private: -- cgit v1.2.3