diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-09-05 20:01:18 +0200 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-09-07 21:15:24 -0700 |
commit | e585caa2bebbd238c763af588a40879b61cf240f (patch) | |
tree | 04efff531c6560533d729874a22c9dbed54b217b /lib | |
parent | eaa9f833098d687ad0c49f96bff0c79650b293b0 (diff) | |
download | android-node-v8-e585caa2bebbd238c763af588a40879b61cf240f.tar.gz android-node-v8-e585caa2bebbd238c763af588a40879b61cf240f.tar.bz2 android-node-v8-e585caa2bebbd238c763af588a40879b61cf240f.zip |
http2: do not crash on stream listener removal w/ destroyed session
Do not crash when the session is no longer available.
Fixes: https://github.com/nodejs/node/issues/29457
PR-URL: https://github.com/nodejs/node/pull/29459
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/internal/http2/core.js | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index 4e633a38e6..7a1847f770 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -426,23 +426,27 @@ function sessionListenerRemoved(name) { // Also keep track of listeners for the Http2Stream instances, as some events // are emitted on those objects. function streamListenerAdded(name) { + const session = this[kSession]; + if (!session) return; switch (name) { case 'priority': - this[kSession][kNativeFields][kSessionPriorityListenerCount]++; + session[kNativeFields][kSessionPriorityListenerCount]++; break; case 'frameError': - this[kSession][kNativeFields][kSessionFrameErrorListenerCount]++; + session[kNativeFields][kSessionFrameErrorListenerCount]++; break; } } function streamListenerRemoved(name) { + const session = this[kSession]; + if (!session) return; switch (name) { case 'priority': - this[kSession][kNativeFields][kSessionPriorityListenerCount]--; + session[kNativeFields][kSessionPriorityListenerCount]--; break; case 'frameError': - this[kSession][kNativeFields][kSessionFrameErrorListenerCount]--; + session[kNativeFields][kSessionFrameErrorListenerCount]--; break; } } |