Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs: fix potential segfault in async calls #18811

Closed
wants to merge 2 commits into from

Commits on Feb 16, 2018

  1. fs: fix potential segfault in async calls

    When the async uv_fs_* call errors out synchronously in AsyncDestCall,
    the after callbacks (e.g. AfterNoArgs) would delete the req_wrap
    in FSReqAfterScope, and AsyncDestCall would set those req_wrap to
    nullptr afterwards. But when it returns to the top-layer bindings,
    the bindings all call `req_wrap->SetReturnValue()` again without
    checking if `req_wrap` is nullptr, causing a segfault.
    
    This has not been caught in any of the tests because we usually do a lot
    of argument checking in the JS layer before invoking the uv_fs_*
    functions, so it's rare to get a synchronous error from them.
    
    Currently we never need the binding to return the wrap to JS layer,
    so we can just call `req_wrap->SetReturnValue()` to return undefined for
    normal FSReqWrap and the promise for FSReqPromise in AsyncDestCall instead
    of doing this in the top-level bindings.
    joyeecheung committed Feb 16, 2018
    Configuration menu
    Copy the full SHA
    1fe23e0 View commit details
    Browse the repository at this point in the history

Commits on Feb 17, 2018

  1. Configuration menu
    Copy the full SHA
    224e88c View commit details
    Browse the repository at this point in the history