Skip to content

Commit

Permalink
http2: avoid race condition in OnHeaderCallback
Browse files Browse the repository at this point in the history
Fixes: nodejs#21416

PR-URL: nodejs#22256
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: George Adams <[email protected]>
  • Loading branch information
jasnell authored and kjin committed Oct 16, 2018
1 parent 411acb7 commit ee3e471
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/node_http2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,12 @@ inline int Http2Session::OnHeaderCallback(nghttp2_session* handle,
Http2Session* session = static_cast<Http2Session*>(user_data);
int32_t id = GetFrameID(frame);
Http2Stream* stream = session->FindStream(id);
CHECK_NE(stream, nullptr);
// If stream is null at this point, either something odd has happened
// or the stream was closed locally while header processing was occurring.
// either way, do not proceed and close the stream.
if (stream == nullptr)
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;

// If the stream has already been destroyed, ignore.
if (stream->IsDestroyed())
return 0;
Expand Down

0 comments on commit ee3e471

Please sign in to comment.