Skip to content

Commit

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

Backport-PR-URL: #22850
PR-URL: #22256
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: George Adams <george.adams@uk.ibm.com>
  • Loading branch information
jasnell authored and BethGriggs committed Oct 16, 2018
1 parent 3980ca1 commit 5c3edd3
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 5c3edd3

Please sign in to comment.