fix: RenderFrameHost nullptr dereference (#45508)
* fix: add nullptr tests before using render_frame_ Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: extract-method HasRenderFrame() Co-authored-by: Charles Kerr <charles@charleskerr.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
parent
cb7eb6fe3d
commit
984b8f9b1b
2 changed files with 11 additions and 5 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue