• tzik's avatar
    Avoid touching ExtendedAuthenticatorImpl's ref count before its fully constructed · 3bc7dce5
    tzik authored
    ExtendedAuthenticatorImpl is a ref counted object. Its first reference
    is taken by base::Bind in its constructor, and the reference is passed
    to GetSystemSalt to do an asynchronous task.
    However, if GetSystemSalt impl drops the passed callback soon, (e.g.
    by PostTask failure), the reference to ExtendedAuthenticatorImpl is
    gone and the instance is destroyed, even before the construction has
    completed. That is, `new ExtendedAuthenticatorImpl` might return a
    stale pointer on the previous code.
    
    This CL adds a static constructor to ExtendedAuthenticatorImpl, and
    moves the problematic part out of the constructor.
    
    Bug: 866456
    Change-Id: I377acc8a753c01a79a4cf09617bfa3b0f6aa923f
    Reviewed-on: https://chromium-review.googlesource.com/1148164Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
    Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#577766}
    3bc7dce5
extended_authenticator.cc 798 Bytes