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/core/frontend/applets/web_browser.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/core/frontend/applets/web_browser.h') diff --git a/src/core/frontend/applets/web_browser.h b/src/core/frontend/applets/web_browser.h index 1c5ef19a9..d7bd44c27 100644 --- a/src/core/frontend/applets/web_browser.h +++ b/src/core/frontend/applets/web_browser.h @@ -16,11 +16,11 @@ public: virtual ~WebBrowserApplet(); virtual void OpenLocalWebPage( - std::string_view local_url, std::function extract_romfs_callback, + const std::string& local_url, std::function extract_romfs_callback, std::function callback) const = 0; virtual void OpenExternalWebPage( - std::string_view external_url, + const std::string& external_url, std::function callback) const = 0; }; @@ -28,11 +28,12 @@ class DefaultWebBrowserApplet final : public WebBrowserApplet { public: ~DefaultWebBrowserApplet() 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; }; -- cgit v1.2.3