Skip to content

Commit 9957916

Browse files
danbevMylesBorins
authored andcommitted
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: #18815 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 0568f75 commit 9957916

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/node_http2.h

+10-6
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,20 @@ void inline debug_vfprintf(const char* format, ...) {
3939
#define DEBUG_HTTP2(...) debug_vfprintf(__VA_ARGS__);
4040
#define DEBUG_HTTP2SESSION(session, message) \
4141
do { \
42-
DEBUG_HTTP2("Http2Session %s (%.0lf) " message "\n", \
43-
session->TypeName(), \
44-
session->get_async_id()); \
42+
if (session != nullptr) { \
43+
DEBUG_HTTP2("Http2Session %s (%.0lf) " message "\n", \
44+
session->TypeName(), \
45+
session->get_async_id()); \
46+
} \
4547
} while (0)
4648
#define DEBUG_HTTP2SESSION2(session, message, ...) \
4749
do { \
48-
DEBUG_HTTP2("Http2Session %s (%.0lf) " message "\n", \
49-
session->TypeName(), \
50-
session->get_async_id(), \
50+
if (session != nullptr) { \
51+
DEBUG_HTTP2("Http2Session %s (%.0lf) " message "\n", \
52+
session->TypeName(), \
53+
session->get_async_id(), \
5154
__VA_ARGS__); \
55+
} \
5256
} while (0)
5357
#define DEBUG_HTTP2STREAM(stream, message) \
5458
do { \

0 commit comments

Comments
 (0)