• Jeroen Dhollander's avatar
    Fix crash in RequestAssistantStructureForActiveBrowserWindow · ff8a3185
    Jeroen Dhollander authored
    This crash has been happening quite frequently since this summer
    (see crbug.com/1128031).
    
    The crash is at line 41:
      assistant_extra->url = web_contents->GetLastCommittedURL();
    Given that we just created |assistant_extra| the line above, it must be
    that |web_contents| is invalid.
    
    |web_contents| is created at line 94:
      content::WebContents* web_contents =
          browser->tab_strip_model()->GetActiveWebContents();
    
    It is surprising that this can be nullptr because we check at line 52
    to ensure the browser is active (so you'd assume it has active web
    content).
    But irregardless, I added a null check after line 94.
    
    Bug: 1128031
    Test: N/A
    Change-Id: Iaabdedf5bb133d608db75a16e96907cc18a0d960
    Cq-Include-Trybots: luci.chrome.try:linux-chromeos-chrome
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2601276
    Commit-Queue: Jeroen Dhollander <jeroendh@chromium.org>
    Reviewed-by: default avatarTao Wu <wutao@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#839458}
    ff8a3185
assistant_context_util.cc 4.42 KB