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@0a8d086

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
+9-8Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,8 @@ Http2Session::~Http2Session() {
548548
ClearWrap(object());
549549
persistent().Reset();
550550
CHECK(persistent().IsEmpty());
551-
for (const auto& iter : streams_)
552-
iter.second->session_ = nullptr;
551+
for (const auto& stream : streams_)
552+
stream.second->session_ = nullptr;
553553
Unconsume();
554554
DEBUG_HTTP2SESSION(this, "freeing nghttp2 session");
555555
nghttp2_session_del(session_);
@@ -1782,11 +1782,11 @@ Http2Stream::Http2Stream(
17821782

17831783

17841784
Http2Stream::~Http2Stream() {
1785-
if (session_ != nullptr) {
1786-
DEBUG_HTTP2STREAM(this, "tearing down stream");
1787-
session_->RemoveStream(this);
1788-
session_ = nullptr;
1789-
}
1785+
if (session_ == nullptr)
1786+
return;
1787+
DEBUG_HTTP2STREAM(this, "tearing down stream");
1788+
session_->RemoveStream(this);
1789+
session_ = nullptr;
17901790

17911791
persistent().Reset();
17921792
CHECK(persistent().IsEmpty());
@@ -1862,7 +1862,8 @@ inline void Http2Stream::Destroy() {
18621862
// We can destroy the stream now if there are no writes for it
18631863
// already on the socket. Otherwise, we'll wait for the garbage collector
18641864
// to take care of cleaning up.
1865-
if (!stream->session()->HasWritesOnSocketForStream(stream))
1865+
if (stream->session() == nullptr ||
1866+
!stream->session()->HasWritesOnSocketForStream(stream))
18661867
delete stream;
18671868
}, this, this->object());
18681869

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.