• Hoch Hochkeppel's avatar
    Initialize PostAsyncResults returned value · fdb8dc55
    Hoch Hochkeppel authored
    Before this change, PostAsyncResults returned a value that was not
    explicitly initialized if the IAsyncOperation failed. This was not
    causing a problem in the code today because ComPtrs are implicitly
    initialized to a valid (though empty) state and all of the consumers of
    this code currently are for IAsyncOperations that return types that
    inherit from IUnknown (which causes the PostAsyncResults method to
    return them inside a ComPtr). If, however, PostAsyncResults is called
    for an IAsyncOperation that returns a different kind of value (e.g. an
    int), the returned value was unitialized memory (in the failure case).
    
    To protect against future use of PostAsyncResults with non-IUnknown
    types (like that planned as part of http://crbug.com/1035527) this
    change adds default value initialization of the result, as well as unit
    tests that validate this behavior and a test-helper class for
    simulating IAsyncOperations.
    
    Bug: 1121285
    Change-Id: If87d817c3cff8830a9e91eeb8fa51d2c32d17f01
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2373165Reviewed-by: default avatarRobert Liao <robliao@chromium.org>
    Reviewed-by: default avatarWez <wez@chromium.org>
    Commit-Queue: Hoch Hochkeppel <mhochk@microsoft.com>
    Cr-Commit-Position: refs/heads/master@{#802241}
    fdb8dc55
post_async_results_unittest.cc 7.19 KB