fix: RenderFrameHost nullptr dereference (#45487)

* fix: add nullptr tests before using render_frame_

* refactor: extract-method HasRenderFrame()
This commit is contained in:
Charles Kerr 2025-02-06 22:02:57 -06:00 committed by GitHub
parent 517935cd55
commit 67f5ac5bbc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 5 deletions

View file

@ -101,8 +101,14 @@ class WebFrameMain final : public gin::Wrappable<WebFrameMain>,
void TeardownMojoConnection();
void OnRendererConnectionError();
// WebFrameMain can outlive its RenderFrameHost pointer so we need to check
// whether its been disposed of prior to accessing it.
[[nodiscard]] constexpr bool HasRenderFrame() const {
return !render_frame_disposed_ && render_frame_ != nullptr;
}
// Throws a JS error if HasRenderFrame() is false.
// WebFrameMain can outlive its RenderFrameHost pointer,
// so we need to check whether its been disposed of
// prior to accessing it.
bool CheckRenderFrame() const;
v8::Local<v8::Promise> ExecuteJavaScript(gin::Arguments* args,