diff options
author | Daniel Bevenius <daniel.bevenius@gmail.com> | 2018-02-16 15:01:16 +0100 |
---|---|---|
committer | Daniel Bevenius <daniel.bevenius@gmail.com> | 2018-02-19 08:17:41 +0100 |
commit | e91ea214115b9e41269415872717ce7a741b1d7a (patch) | |
tree | e26a763986060c56468542e37a53c723bd168ff3 /src/node_http2.h | |
parent | 12412ef43fb4aa8eef39defad949aa8d1fe6aa10 (diff) | |
download | android-node-v8-e91ea214115b9e41269415872717ce7a741b1d7a.tar.gz android-node-v8-e91ea214115b9e41269415872717ce7a741b1d7a.tar.bz2 android-node-v8-e91ea214115b9e41269415872717ce7a741b1d7a.zip |
src: add nullptr check for session in DEBUG macro
Currenlty when configuring --debug-http2
/test/parallel/test-http2-getpackedsettings.js will segment fault:
$ out/Debug/node test/parallel/test-http2-getpackedsettings.js
Segmentation fault: 11
This is happening because the settings is created with the Environment in
PackSettings:
Http2Session::Http2Settings settings(env);
This will cause the session to be set to nullptr. When the init
function is later called the expanded DEBUG_HTTP2SESSION macro will
cause the segment fault when the session is dereferenced.
PR-URL: https://github.com/nodejs/node/pull/18815
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_http2.h')
-rw-r--r-- | src/node_http2.h | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/node_http2.h b/src/node_http2.h index 0e81eaac6c..217c19c092 100644 --- a/src/node_http2.h +++ b/src/node_http2.h @@ -39,16 +39,20 @@ void inline debug_vfprintf(const char* format, ...) { #define DEBUG_HTTP2(...) debug_vfprintf(__VA_ARGS__); #define DEBUG_HTTP2SESSION(session, message) \ do { \ - DEBUG_HTTP2("Http2Session %s (%.0lf) " message "\n", \ - session->TypeName(), \ - session->get_async_id()); \ + if (session != nullptr) { \ + DEBUG_HTTP2("Http2Session %s (%.0lf) " message "\n", \ + session->TypeName(), \ + session->get_async_id()); \ + } \ } while (0) #define DEBUG_HTTP2SESSION2(session, message, ...) \ do { \ - DEBUG_HTTP2("Http2Session %s (%.0lf) " message "\n", \ - session->TypeName(), \ - session->get_async_id(), \ + if (session != nullptr) { \ + DEBUG_HTTP2("Http2Session %s (%.0lf) " message "\n", \ + session->TypeName(), \ + session->get_async_id(), \ __VA_ARGS__); \ + } \ } while (0) #define DEBUG_HTTP2STREAM(stream, message) \ do { \ |