• tzik's avatar
    Avoid touching ThreatDetails's ref-count before it's fully constructed · ed031ddf
    tzik authored
    ThreatDetails is a ref counted object, and its first reference can be
    made by base::BindRepeating through ThreadDetails::StartCollection.
    The ref count is released when the callback instance is destroyed.
    
    As the RepeatingCallback instance created in StartCollection is
    destroyed after the scope out, `new ThreatDetails` may have returned
    a stale pointer.
    
    This CL moves the problematic StartCollection() call out of the
    constructor to avoid touching the ref count before its first proper
    reference is made.
    
    Bug: 866456
    Change-Id: I82b83b9bb30cdc95cff60e3e22e79f0af17645a2
    Reviewed-on: https://chromium-review.googlesource.com/1149777Reviewed-by: default avatarJialiu Lin <jialiul@chromium.org>
    Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#577962}
    ed031ddf
trigger_manager_unittest.cc 19.5 KB