fix: prevent destroyed view references from causing crashes (#25411)
Closes #21666. This PR is fixing crashes caused by referencing and attempting to modify previously destroyed views. Before, when a view was destroyed and then the contents were referenced for modification, the system would crash as undefined memory was accessed. This fix explicitly makes the pointer to the destroyed view's contents null, so that this will not happen.
This commit is contained in:
parent
e0a25cb1e3
commit
53aaeb7a16
5 changed files with 90 additions and 21 deletions
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "base/macros.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
|
||||
namespace gfx {
|
||||
|
@ -27,9 +28,9 @@ enum AutoResizeFlags {
|
|||
class InspectableWebContents;
|
||||
class InspectableWebContentsView;
|
||||
|
||||
class NativeBrowserView {
|
||||
class NativeBrowserView : public content::WebContentsObserver {
|
||||
public:
|
||||
virtual ~NativeBrowserView();
|
||||
~NativeBrowserView() override;
|
||||
|
||||
static NativeBrowserView* Create(
|
||||
InspectableWebContents* inspectable_web_contents);
|
||||
|
@ -52,6 +53,8 @@ class NativeBrowserView {
|
|||
|
||||
protected:
|
||||
explicit NativeBrowserView(InspectableWebContents* inspectable_web_contents);
|
||||
// content::WebContentsObserver:
|
||||
void WebContentsDestroyed() override;
|
||||
|
||||
InspectableWebContents* inspectable_web_contents_;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue