Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion proxy/http2/Http2Stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,8 @@ Http2Stream::destroy()

// Safe to initiate SSN_CLOSE if this is the last stream
if (_proxy_ssn) {
cid = _proxy_ssn->connection_id();

Http2ClientSession *h2_proxy_ssn = static_cast<Http2ClientSession *>(_proxy_ssn);
SCOPED_MUTEX_LOCK(lock, h2_proxy_ssn->connection_state.mutex, this_ethread());
// Make sure the stream is removed from the stream list and priority tree
Expand All @@ -766,7 +768,7 @@ Http2Stream::destroy()
// Update session's stream counts, so it accurately goes into keep-alive state
h2_proxy_ssn->connection_state.release_stream(this);

cid = _proxy_ssn->connection_id();
// Do not access `_proxy_ssn` in below. It might be freed by `release_stream`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks familiar. Don't we have a similar comment somewhere? Or did we remove it and now putting it back? We may want something we can avoid the heap-use-after-free.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one? I agree with we need something.

ua_session->destroy();
// Can't do this because we just destroyed right here ^,
// or we can use a local variable to do it.
// ua_session = nullptr;

}

// Clean up the write VIO in case of inactivity timeout
Expand Down