GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — http2: safer Http2Session destructor · nodejs/node@dee250f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • node_http2.cc
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/node_http2.cc‎

Copy file name to clipboardExpand all lines: src/node_http2.cc
+8-7Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,8 @@ Http2Session::Http2Session(Environment* env,
499499
Http2Session::~Http2Session() {
500500
CHECK_EQ(flags_ & SESSION_STATE_HAS_SCOPE, 0);
501501
Debug(this, "freeing nghttp2 session");
502-
for (const auto& iter : streams_)
503-
iter.second->session_ = nullptr;
502+
for (const auto& stream : streams_)
503+
stream.second->session_ = nullptr;
504504
nghttp2_session_del(session_);
505505
}
506506

@@ -1710,11 +1710,11 @@ Http2Stream::Http2Stream(
17101710

17111711

17121712
Http2Stream::~Http2Stream() {
1713+
if (session_ == nullptr)
1714+
return;
17131715
Debug(this, "tearing down stream");
1714-
if (session_ != nullptr) {
1715-
session_->RemoveStream(this);
1716-
session_ = nullptr;
1717-
}
1716+
session_->RemoveStream(this);
1717+
session_ = nullptr;
17181718
}
17191719

17201720
std::string Http2Stream::diagnostic_name() const {
@@ -1789,7 +1789,8 @@ void Http2Stream::Destroy() {
17891789
// We can destroy the stream now if there are no writes for it
17901790
// already on the socket. Otherwise, we'll wait for the garbage collector
17911791
// to take care of cleaning up.
1792-
if (!stream->session()->HasWritesOnSocketForStream(stream))
1792+
if (stream->session() == nullptr ||
1793+
!stream->session()->HasWritesOnSocketForStream(stream))
17931794
delete stream;
17941795
}, this, this->object());
17951796

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.